Writing and reading Hex values to ASC0 or ASC1 port via Java in EHS6T | Thales IoT Developer Community
May 5, 2018 - 4:35am, 2422 views
I am currently trying to write hex values as a command of sorts to the serial port via either ASC0 or ASC1; I am trying to read the response as hex values of its corresponding response data.
In this project, I have tried the following, attached in the below pastebin link:
Whether sending it to file output or debug standard screen output, I am finding it returns pure gibberish characters or data and what seems to be endless output of line spaces.
What can you advise for the following:
1. 1. Can I use either ASC0 or ASC1 to write and read to the serial port?
2. 2. If I can, what is the AT commands configurations if any that need to be changed to allow this write read of the serial port once its allocated and in use?
3. 3. From the code, have I properly written hex values in code or is there a way to write and get back hex values in Java ME (which as you may know offers less functions for datatype conversion and casting than subsequent Java SDKs, such as Integer.toHexString being unavailable in ME’s Java 1.3?) You'll see that I wrote the values as byte equivalents of binary string. So do I need to write them as like 0x00 numbers and then cast them as bytes instead?
4. 4. Is the overall code I provided properly writing once to serial port as the OutputStream object and properly reading in the resulting InputStream ?
5. 5. Do you have any other examples other than the RS232 demo to show how we can write to port, THEN read the input port?
Nothing seems to write to the InputStream and the resulting available bytes is always 0.
When we read the serial port in Windows in Hterm, we normally receive this type of response data as you see in the screenshot.
And that’s what I am trying to emulate in terms of functionality in Java ME and the Gemalto but just don’t know quite how to.
Not sure quite what Im doing in Java so any advice or light you could shed on this, as always, is greatly appreciated.
Thanks once again.