gp2112 / arduino-rs232

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Serial Communication in Arduino ~ RS-232

Demonstration Video

This is a simple implementation of a serial comunication protocol, based on RS-232, on Arduino, for Computer Networks class.

Group Members

Compatibility

This code was made for Arduino UNO. For other Arduinos versions, you may have to change it's registers.

Compiling and Upload

If you use Arduino's IDE, you can just open the project on it aaand run!

If you prefer to use some other IDE or Text Editor, you have this power too!

If your system is not recognizing Arduino (Linux):

  1. Add your user to UUCP group (you may use sudo for this)
usermod -aG uucp YOUR-USER
  • Restart your system
  1. Check if cdc_acm module is already activated in your system:
lsmod | grep cdc_acm
  • If nothing is returned, than you need to activate it (you may need sudo):
modprobe cdc_acm
  • If you wish to load this module automaticaly each time your system boots, if your're using systemd: (you may use sudo)
echo "cdc_acm" > /etc/modules-load.d/cdc_acm.conf

If you don't want to use Arduino's IDE (Linux):

yea, I don't like it too...

  1. Install arduino-cli
  2. Create the configuration file:
arduino-cli config init
  1. Install your arduino core drivers. This code was made for Arduino UNO, so:
arduino-cli core update-index
arduino-cli core install arduino:avr
  1. Now you can compile and upload to your board using the Makefile.
  • OBS: You must make configure every time you plug your rduino in.
  1. To get arduino's output just execute ./listen and to send an input, ./send YOUR-INPUT

Protocol Specification

This protocol specifies the transmission for each byte and it bit parity

1. Handshake

  1. Emissor sets RTS to 1 and waits for CTS signal
  2. When receiving RTS signal, Receptor sets CTS to 1
  3. Emissor, then, begins the transmission with the clock

2. Data Transmission

  1. For each clock transition (0 to 1), receptor reads data from TX port
  2. In the end of the reception, the emissor stops the clock and clean RTS to 0

3. Closing conection

  1. When receptor stops receiving RTS signal, it verifies the bit parity
  2. If the parity is right, it prints the data.
  3. The receptor, then, puts the CTS to 0.

image

About


Languages

Language:C++ 67.2%Language:C 22.7%Language:Makefile 8.5%Language:Shell 1.6%