Answer the question
In order to leave comments, you need to log in
Receiving data from Arduino in the Linux console. How?
Good time of the day!
There is an Arduino that sends a constant stream of data to a Linux computer. The data goes through /dev/ttyACM0.
Question: how to read data from it and save it to serial_port.data file?
cat /dev/ttyACM0 > serial_port.data
tail -f /dev/ttyACM0 > serial_port.data
tail -f /dev/ttyACM0
cat /dev/ttyACM0 >> serial_port.data
Answer the question
In order to leave comments, you need to log in
Don't forget about stty and COM port setting. I have setup with this command.
stty -F /dev/ttyACM0 cs8 9600 ignbrk -brkint -icrnl -imaxbel -opost -onlcr -isig -icanon -iexten -echo -echoe -echok -echoctl -echoke noflsh -ixon -crtscts raw
code for Arduino:
Serial.begin(9600); Serial.println("START");
#!/bin/sh insmod usbserial insmod ftdi_sio insmod cdc-acm while[true] do stty -F /dev/ttyACM0 cs8 9600 ignbrk -brkint -icrnl -imaxbel -opost -onlcr -isig -icanon -iexten -echo -echoe -echok -echoctl -echoke noflsh -ixon -crtscts raw while read LINE do echo $LINE done < /dev/ttyACM0 /bin/sleep 3 done
Try
while [ 1 ]; do
DATA=`dd if=/dev/ttyACM0 count=1`
echo $DATA
done
have you tried hexdump? and what's the problem with writing your own logger program? )
It seemed to me that it would be nice to collect data using console means. I'll try hexdump, thanks!
As far as I understand, you should dig in the direction of presetting data transfer parameters like baud rate and parity. If they are set incorrectly, then you will receive garbage instead of data. It seems like the setserial utility can do this.
hmm, came across a question. the situation is similar (arduina, linux), arduina pours temperature data every second T = ***
I decided like this:
#!/bin/bash
DATEFORMAT=$(date '+%m/%d/%y %H:%M:%S') #формат таймстампа
DEVICE='/dev/ttyACM0' #порт устройства
echo $(head -n 1 $DEVICE) $DATEFORMAT >> temperature.csv #само собой перекидка в файл, каждая запись новой строкой.
I am running the following script:
#!/bin/sh
stty -F /dev/ttyUSB0 cs8 9600 ignbrk -brkint -icrnl -imaxbel -opost -onlcr -isig -icanon -iexten -echo -echoe -echok -echoctl -echoke noflsh -ixon -crtscts raw
cat /dev/ttyUSB0 > serial_port.data
exit
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question