For a comfortable readout and interaction the measurements from the caliper are sent to a standard android tablet. Data is exchanged via a USB serial connection. To establish the connection Android provides UsbManager which can be used to get a device list and find the desired device based on vendorID and productID. To get those IDs something like lsusb for linux or USBView for Windows does the trick.
Once the device is found, permission to access has to be obtained from the user. BroadcastReceiver is used to handle the asynchronous response. After receiving permission UsbDevice is used to find the correct interface/endpoints for communication. Setting up BaudRate etc. can be done manually by using UsbDeviceConnection.controlTransfer(...) if the correct values for requestID and the parameters are known. They might have to be looked up in the documentation of the USB adapter and might need some fiddling around until the desired configuration works. An alternative is the use of a USBSerial library like https://github.com/felHR85/UsbSerial can be used.
In my setup the communication runs at 115200 8N1 via the bulk transfer endpoints without any noticeable connection problems.
To organize the data transfer a very simple request response protocol is used. The microcontroller keeps waiting for a request from the Android host. The standard request (“0x01”) makes the controller read and send the value from the caliper. To get the value the controller polls on the clock line for a long enough pause between HIGH/LOW to make sure a new measurement begins. More polling on the clock and reading the data line retrieves the 24 data bits. The value is send back as a two byte integer to the Android host. The host keeps accumulating bytes until the response is completed and displays the value.
ToDo next: Upgrade the UI with features for resetting offsets etc. And then its finally time to attach everything to the lathe.