0

I'm having problems sending an echo to an a RFID reader. In one terminal I'm running a cat like cat < /dev/ttyUSB0 and in another one I'm sending an echo like echo $'\x80\x80\x80\x01\x01\x01\x11\x14' > /dev/ttyUSB0, where the bytes are the command for initializing the reader. Nothing happens...

The RFID readers come with an specific software that actually make them work. But when I want to replicate the same behavior with my programe, I can not get it to work.

My hypothesis is that maybe the echo is not actually writing the bytes to the serial port, and maybe all the data is stored somewhere waiting for some kind of another signal.

I know that the question is not quite specific, but I only want to know if maybe I'm ignoring some basic stuff related to serial communication.

Thanks.

sawdust
  • 16,103
  • 3
  • 40
  • 50
Aleix Vila
  • 103
  • 3
  • 1
    *"maybe I'm ignoring some basic stuff"* -- You are ignoring the fact that you are using a serial terminal (the "tty" in the device name), which can be configured for either canonical (lines of text) or non-canonical (binary data, aka raw) modes. Canonical mode is typically the default, so your `cat` command would block until an end-of-line character (e.g. '\n') was received. Learn how to use the `stty` command (e.g. `man stty`). Use `stty raw -F /dev/ttyUSB0` to put the serial terminal into non-canonical mode. Note that there is no hyphen in front of the `raw` parameter. – sawdust Jan 16 '18 at 01:14
  • 1
    You also need to be sure that the serial port is properly configured as the remote device (e.g. the RFID reader) requires. Again the `stty` command can report and/or configure the salient parameters (e.g. baudrate, data size, parity, handshake). Improper settings can result in a non-responsive device just like your *"nothing happens"* situation. – sawdust Jan 16 '18 at 01:24

0 Answers0