0.5.1 RS485

This commit is contained in:
Rob Tillaart 2024-04-16 21:03:41 +02:00
parent 568d35f292
commit f350a8cf30
9 changed files with 46 additions and 12 deletions

View File

@ -6,6 +6,14 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/)
and this project adheres to [Semantic Versioning](http://semver.org/).
## [0.5.1] - 2024-04-04
- improve **flush()** to work for STM32
- add **void setMicrosPerByte(mpb)** to set delay after flush() for last byte.
- add **uint16_t getMicrosPerByte()**
- update GitHub actions
- minor edits
## [0.5.0] - 2024-02-01
- merge PR #28, Fix for FS conflict on ESP32 (kudos to DoomHammer)
- all ASCII control characters get a **ASCII_** prefix.

View File

@ -107,6 +107,20 @@ An important command from the stream interface is the **setTimeOut()** as
this allows reads on the RS485 bus that are limited.
#### setMicrosPerByte
**Experimental**
To add a small delay after **flush()** to be sure that the last byte in the
TX register has time to be sent.
It prevents a premature switching from transmit to receive mode.
The default value is 1100 (9600 baud time) and can be tuned, e.g. when high
baud rates are used it can be smaller.
- **void setMicrosPerByte(uint16_t mpb)**
- **uint16_t getMicrosPerByte()** returns set value, default 1100 (9600 baud time).
#### Experimental
Work in progress. The library has an **experimental** protocol implemented to
@ -223,6 +237,7 @@ Would allow 127 different 1 byte commands.
- dynamic receive buffer size?
- investigate error handling?
- test other platforms
- STM32 (see issue 30)
- ESP32.
#### Could
@ -232,6 +247,7 @@ Would allow 127 different 1 byte commands.
- multi-master?
- add unit tests
- investigate yield() on ESP32/RTOS behaviour
- investigate non-blocking version.
#### Wont

View File

@ -2,7 +2,7 @@
// FILE: RS485.cpp
// AUTHOR: Rob Tillaart
// DATE: 30-okt-2017
// VERSION: 0.5.0
// VERSION: 0.5.1
// PURPOSE: Arduino library for RS485 modules (MAX485)
// URL: https://github.com/RobTillaart/RS485
@ -55,7 +55,12 @@ int RS485::peek()
void RS485::flush()
{
#ifdef ARDUINO_ARCH_STM32
while (Serial.availableForWrite() < ( SERIAL_TX_BUFFER_SIZE - 1));
#else
_stream->flush();
#endif
delayMicroseconds(_microsPerByte); // for the last byte.
}

View File

@ -3,7 +3,7 @@
// FILE: RS485.h
// AUTHOR: Rob Tillaart
// DATE: 30-okt-2017
// VERSION: 0.5.0
// VERSION: 0.5.1
// PURPOSE: Arduino library for RS485 modules
// URL: https://github.com/RobTillaart/RS485
@ -11,7 +11,7 @@
#include "Arduino.h"
#include "ASCII_CONTROL.h"
#define RS485_LIB_VERSION (F("0.5.0"))
#define RS485_LIB_VERSION (F("0.5.1"))
class RS485 : public Stream
@ -54,12 +54,16 @@ public:
size_t send(uint8_t receiverID, char msg[], uint8_t len);
bool receive(uint8_t &senderID, char msg[], uint8_t &len);
// EXPERIMENTAL
void setMicrosPerByte(uint16_t mpb) { _microsPerByte = mpb; };
uint16_t getMicrosPerByte() { return _microsPerByte; };
private:
Stream * _stream;
uint8_t _sendPin = 0;
uint8_t _deviceID = 0;
uint16_t _microsPerByte = 1000;
uint16_t _microsPerByte = 1100;
// EXPERIMENTAL
uint8_t _bidx = 0;

View File

@ -6,6 +6,7 @@
// minimal test to see how fast data can be send over the
// RS485 bus at a given baud rate of 4800. (adjust if needed).
#include "Arduino.h"
#include "RS485.h"

View File

@ -15,7 +15,7 @@
"type": "git",
"url": "https://github.com/RobTillaart/RS485"
},
"version": "0.5.0",
"version": "0.5.1",
"license": "MIT",
"frameworks": "*",
"platforms": "*",

View File

@ -1,5 +1,5 @@
name=RS485
version=0.5.0
version=0.5.1
author=Rob Tillaart <rob.tillaart@gmail.com>
maintainer=Rob Tillaart <rob.tillaart@gmail.com>
sentence=RS485 library for Arduino.