Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Sending bytes to serial port from UNIX command line?

i would like to send a stream of bytes to a serial port using the command line. is this possible? my serial port is at /dev/cu.usbserial-A700dYoR on my Mac. for example, if i wanted to send the integer 50 or the string "data" to that serial port, how can i do that?

my knowledge of UNIX is very limited.

like image 760
Chunky Chunk Avatar asked Sep 28 '10 21:09

Chunky Chunk


1 Answers

#!/bin/bash

# Port setting
stty -F /dev/cu.usbserial-A700dYoR raw speed 9600

echo 'Hello' > /dev/cu.usbserial-A700dYoR

or something like that if I remember correctly... Been a few years. You will probably have to be sudo for it to work...

This is sending text... not binary.. to send the number 50 as text

echo '50' > /dev/cu.usbserial-A700dYoR

to send it as a binary integer would be more difficult.

like image 169
Justin808 Avatar answered Sep 29 '22 05:09

Justin808