The Broadcom UART appears as
/dev/ttyAMA0 under Linux. There are several minor things in the way if you want to have dedicated
control of the serial port on a Raspberry Pi. This link describes the process for free the serial port: http://elinux.org/RPi_Serial_Connection. There is a brief script to automate the same steps: https://github.com/lurch/rpi-serial-console.If you want to test the serial port to send/receive data:
- First have a look at the permissions on that file, lets assume you are using
/dev/ttyAMA0:
ls -l /dev/ttyAMA0- You will want read.write access, if this is a shared system then you should consider the security consequences of opening it up for everyone:
chmod o+rw /dev/ttyAMA0
- You have to setup the baud rate with the next instruction:
stty 115200 -F /dev/ttyAMA0- A very simple crude method to write to the file (send data to the serial port), would use the simple
echocommand in one terminal:
echo -ne 'ri_07_02' > /dev/ttyAMA0
- And to read use the
minicomcommand (maybe with another terminal):
minicom -b115200-o -D /dev/ttyAMA0
No hay comentarios:
Publicar un comentario