Send arbitrary byte to ASC0 | Telit Cinterion IoT Developer Community
December 11, 2015 - 11:01am, 2754 views
Hello,
I am working with Concept EHS6 board. I can run the RS232 demo (Java) which receive and echo back ASCII character from ASC0. However, I would like to send an arbitrary byte (not ascii character) to ASC0, whenever I send a not-ascii byte, the system auto converts to 0x3F ('?' ascii) and send out. How can I configure the system so that I can send out any byte I want?
Thank you and looking forward to your help.
Hello,
The read() method in the demo MIDlet reads a byte and returns it as int. Then it is displayed by the MIDlet as char and sent back. The write() method takes int and sends byte (eight low-order bits of the argument). So the same byte should be returned by the application.
What you send form your system probably depends on terminal that you are using. What software are you using on PC to send data on serial? Generally the serial terminal programs are probably rather designed for sending and receiving text but I'm sure that you'll be able to find one that can also send and receive any byte (HTerm for example).
Regards,
Bartłomiej
Hi Bartlomiej,
Thanks for your reply, it is correct when I send an ascii character. However, when I tried to modify the program so that the concept board sent bytes which are from 0x7F ~ 0xFF, my PC terminal always displays 0x3F. The terminal I am using is a customized one that can display hexa string from received byte array. Please have a look on my modified java code:
try {
int ch = -1;
while(ch != 'Q') {
ch = inStream.read();
if (ch >= 0) {
outStream.write(ch); // --> PC terminal display correctly hexa code
int co = 0xff;
outStream.write(co); // --> PC terminal receives 0x3F ('?')
co = 0xD4;
outStream.write(co); // --> PC terminal receives 0x3F ('?')
System.out.print((char)ch);
}
}
} catch(IOException e) {
System.out.println(e);
}
When I reread the EHS6 AT command manual, I found a section of AT+CSCS that set character set of the serial, by default it is set to "GSM" which is 7 bit ASCII. And I found this sentence : "
"When you enter characters that are not valid characters of the supported alphabets the behavior is undefined."
Could you recheck this setting as I want EHS6 to communicate with an UART shield.
Thank you and regards,
Thanh
Hi Bartlomiej,
You are correct, I have checked my PC terminal code, it converts received bytes to ascii code that makes this problem happen.
Thank you for your help.
Regards,
Thanh
Hello,
Great!
By the way the AT+CSCS command has no influence on serial interface. It's for character set setting for AT commands interface, which can be accessed on external serial or USB or from Java via ATCommand API.
Regards,
Bartłomiej