I am working a serial stepper motor controller and programming it in C. The problem I have run into is that the controller returns values in binary representations and I am not sure how to display. Obviously converting it to int is not an option as I need the exact binary representation that the controller sends.
The output is of the form: MSB -> LSB (Most Significant Bit to Least Significant Bit).
At the moment I am trying something like:
char buff[] = "@01 STAT\r";
char readbuff[10];
fd = open("/dev/ttyS0", O_RDWR | O_NOCTTY | O_NDELAY);
n = write (fd,buff, len);
......
n = read(fd, readbuff, 3);
printf("STAT returns %c\n", readbuff);
......
This returns nonsensical data ie weird shapes and symbols. I have set output to raw and am using 0 parity. I have skipped the initialization parameters but can add them if it helps.
If anyone is curious I am using an Ocean Control KTA-190 Serial Stepper Motor.