Documentation Arduino base program code
DpSerialCommunication Arduino library provide function for Serial communication format on standard way for diferent Serial ports.
Source code is provided as is, without any warranty.
Distributed under CC BY v 3.0
// inicialisation DpSerialCommunication(); // Setting communication parameters // serIn pointer to HardwareSerial communication cannel // baud communication bauds setting void begin(HardwareSerial *serIn, int baud); // return maximal body length in bytes byte getMaxBody(void); // return maximal uuid length byte getMaxUuid(void); // send command #cmd#uuid#body#\r\n and return true for successfuly // response (response body is in body) or false for unsuccessful transaction // uuid - unique uid // body - command body // ws - waiting seconds for response // outside configuration must provide enought large char array for uuid and body boolean sendCMD(char uuid[], char body[], byte ws = 1); // wait command #cmd#uuid#body#\r\n and return true when command was received // or false for unsuccessful transaction // uuid - unique uid of command // body - command body // ws - waiting seconds for command // outside configuration must provide enought large char array for uuid and body boolean waitCMD(char uuid[], char body[], byte ws = 1); // send response #res#uuid#body#\r\n // uuid - unique uid of command // body - response body // outside configuration must provide enought large char array for uuid and body void sendRES(char uuid[], char body[]); // wait one line from communication channel (finished with \r\n) and return true when // line was received or false for unsuccessful transaction // wLine - line of chars // ws - waiting seconds for line // outside configuration must provide enought large char array for wLine boolean getLine(char wLine[], byte ws); // send one line to communication channel (finished with \r\n) // wLine - line of chars // outside configuration must provide enought large char array for wLine void sendLine(char wLine[]);
Author: Dubravko Penezic
Email: dpenezic@gmail.com