feed all

مطالب مرتبط با «shell read answer» در feed all | نویسنده: استخدام کار

Shell read answer from USB device

Hi all,I need to read answer from an USB device after I've sent it a command.I can send the wanted code to /dev/ttyUSB0 using the following script: Code: #! /bin/bash # launch with ./program.sh filename # file has to be in HEX mode, exemple: # x02x33x07 # but file contents looks like: # 02 03 07 # init serial port for USB device stty -F /dev/ttyUSB0 38400 cs8 parenb # replace all occurences of space by x in file passed as argument sed -i 's| |\x|g' "$1" # remove empty lines in file passed as argument sed -i '/^$/d' "$1" # send each line to serial port, pause between each line while read -r line do # add x for the 1st hex code and send line to USB device echo -ne 'x'"$line" >/dev/ttyUSB0 # le...

ادامه مطلب