With the SimpleComm library you can send data through any Arduino Stream: RS-485, RS-232, Ethernet… It is enough flexible to support different kind of communication typologies: Ad-hoc, Master-Slave, Client-Server… Using an easy to use API. The SimpleCoom library is included on Tools40 library.
SimplePacket encapsulates the data into a packet and provides these functions:
Fill up the packet with the desired data to send or the received data from a remote device. It is possible to fill up the packet with different types of data: bool, char, unsigned char, int, unsigned int, long, unsigned long, double, const, const char, const void.
Return the data contained in the packet, depending on the data type. If length is specified, it returns the data length in bytes.
SimpleComm is the interface for sending and receiving packets through the desired Arduino Stream:
Enable the communication system and set the device identifier/address. The address is used to identify each device. The device receives packets that are sent to it, but not to others.
send(stream, packet, destination)
send(stream, packet, destination, type)
Send a packet to a destination device, using the stream. It is also possible to define the packet type.
Receive a packet sent to me from another device, using the stream. It returns true if a packet is received.
How to install the Tools40 library in the Arduino IDE.
- Download the Tools40 library from the GitHub. Click on: “Clone or download”. After that download the zip file on your desktop.
- Add the library on the Arduino IDE. Click on: Sketch–>Include library–>Add .ZIP library and choose “arduino-Tools40-master.zip”. After choose the arduino-Tools40-master.zip the library has to be charged. To verify the library is added correctly you can see the library on: //File–>Examples–>Tools40
- Now your library is correctly installed and you can see an example to how to use that library on our PLCs.