Read ASCII values from serial port

Hello,

I am sending commands to a robot controller, such as Home
, Move
from a Java program using Java COMM API, through a serial port, they are working fine.

Generally, I use a robot s/w (DOS based) to send commands to the controller. When we press "~" (SHIFT_~ actually) from robot s/w then the controller goes into Manual Mode, once the controller is in Manual Mode we can use keys 1,2,3 on keyboard to move the robot in X+, Y+ & Z+ directions.

When I send "~" from Java program to the controller through serial port, the Java program is receiving correct controller response, but once in Manual Mode when I send "1" from the same Java program, the robot does not move.
According to the robot manufacturing company, there are some non-printable characters which are sent to the controller along with "1" .

To read all characters going to controller when "1" is pressed, I connected 2 PCs --> PC-1 running SimpleRead.java and at PC-2 robot s/w opened.
when "1" is pressed in robot s/w, at PC-2 I can read "1" but I can not read those non-printable characters.
My intention is to get & print the ascii values of all those characters coming at the serial port when "1" is pressed, so that we will know all the characters.
How can we read & print ASCII values of characters coming at serial port in Java, C, VC++?
In SimpleRead.java--> a byte array is used to store the incoming data and then print.

byte[] readBuffer = new byte[20];
System.out.print(new String(readBuffer));

Thank You !!
Mayur

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories