raspberry-pihexuartraspberry-pi4bytestream

Byte communication between RPI4 and Wavesharemodule via uart


I have bought the wavesharebarcodereader module (https://www.waveshare.com/wiki/Barcode_Scanner_Module) and managed that it decodes codes and sends the data to the rpi. Now i try to use it in command Mode where i can trigger the scanning by sending a byte array. The Manual says this:

In my understanding this is an Array of Hexadecimal bytes so i need to suffix each byte with a 0x so i wrote echo "0x7E 0x00 0x08 0x01 0x00 0x02 0x01 0xAB 0xCD" > /dev/serial0 and the voltage of the tx pin drops for a moment as if it would send but the device doesnt react or answer. I also tried without the quotes or single quotes or without the 0x suffix but the device doesnt "understand" it and doesnt react. Im sure the cabeling is correct and i tested the pins by connecting rx to tx straight and that works too. The barcodereader does work on 3.3V pins too so that is not the problem. I also tried sending the bytes with an arduino but the reader doesnt respond to that either. Sadly all the Documentation on the Reader is this: https://www.waveshare.com/w/upload/d/dd/Barcode_Scanner_Module_Setting_Manual_EN.pdf

Ive been stuck on this problem super long because im very new to uart bytes so any help would be appreciated.


Solution

  • Alright i figured it out: i needed to use the command: printf "%b" '\x7E\x00\x08\x01\x00\x02\x01\xAB\xCD' > /dev/serial0 and that worked