com.hoho.android.usbserial.util.HexDump Java Examples
The following examples show how to use
com.hoho.android.usbserial.util.HexDump.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: TerminalFragment.java From usb-serial-for-android with GNU Lesser General Public License v2.1 | 6 votes |
private void send(String str) { if(!connected) { Toast.makeText(getActivity(), "not connected", Toast.LENGTH_SHORT).show(); return; } try { byte[] data = (str + '\n').getBytes(); SpannableStringBuilder spn = new SpannableStringBuilder(); spn.append("send " + data.length + " bytes\n"); spn.append(HexDump.dumpHexString(data)+"\n"); spn.setSpan(new ForegroundColorSpan(getResources().getColor(R.color.colorSendText)), 0, spn.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); receiveText.append(spn); usbSerialPort.write(data, WRITE_WAIT_MILLIS); } catch (Exception e) { onRunError(e); } }
Example #2
Source File: TerminalFragment.java From usb-serial-for-android with GNU Lesser General Public License v2.1 | 5 votes |
private void receive(byte[] data) { SpannableStringBuilder spn = new SpannableStringBuilder(); spn.append("receive " + data.length + " bytes\n"); if(data.length > 0) spn.append(HexDump.dumpHexString(data)+"\n"); receiveText.append(spn); }