mirror of
https://github.com/RobTillaart/Arduino.git
synced 2024-09-19 16:46:11 -04:00
0.5.1 RS485
This commit is contained in:
parent
568d35f292
commit
f350a8cf30
@ -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/).
|
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
|
## [0.5.0] - 2024-02-01
|
||||||
- merge PR #28, Fix for FS conflict on ESP32 (kudos to DoomHammer)
|
- merge PR #28, Fix for FS conflict on ESP32 (kudos to DoomHammer)
|
||||||
- all ASCII control characters get a **ASCII_** prefix.
|
- all ASCII control characters get a **ASCII_** prefix.
|
||||||
|
@ -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.
|
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
|
#### Experimental
|
||||||
|
|
||||||
Work in progress. The library has an **experimental** protocol implemented to
|
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?
|
- dynamic receive buffer size?
|
||||||
- investigate error handling?
|
- investigate error handling?
|
||||||
- test other platforms
|
- test other platforms
|
||||||
|
- STM32 (see issue 30)
|
||||||
- ESP32.
|
- ESP32.
|
||||||
|
|
||||||
#### Could
|
#### Could
|
||||||
@ -232,6 +247,7 @@ Would allow 127 different 1 byte commands.
|
|||||||
- multi-master?
|
- multi-master?
|
||||||
- add unit tests
|
- add unit tests
|
||||||
- investigate yield() on ESP32/RTOS behaviour
|
- investigate yield() on ESP32/RTOS behaviour
|
||||||
|
- investigate non-blocking version.
|
||||||
|
|
||||||
#### Wont
|
#### Wont
|
||||||
|
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
// FILE: RS485.cpp
|
// FILE: RS485.cpp
|
||||||
// AUTHOR: Rob Tillaart
|
// AUTHOR: Rob Tillaart
|
||||||
// DATE: 30-okt-2017
|
// DATE: 30-okt-2017
|
||||||
// VERSION: 0.5.0
|
// VERSION: 0.5.1
|
||||||
// PURPOSE: Arduino library for RS485 modules (MAX485)
|
// PURPOSE: Arduino library for RS485 modules (MAX485)
|
||||||
// URL: https://github.com/RobTillaart/RS485
|
// URL: https://github.com/RobTillaart/RS485
|
||||||
|
|
||||||
@ -55,7 +55,12 @@ int RS485::peek()
|
|||||||
|
|
||||||
void RS485::flush()
|
void RS485::flush()
|
||||||
{
|
{
|
||||||
|
#ifdef ARDUINO_ARCH_STM32
|
||||||
|
while (Serial.availableForWrite() < ( SERIAL_TX_BUFFER_SIZE - 1));
|
||||||
|
#else
|
||||||
_stream->flush();
|
_stream->flush();
|
||||||
|
#endif
|
||||||
|
delayMicroseconds(_microsPerByte); // for the last byte.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
// FILE: RS485.h
|
// FILE: RS485.h
|
||||||
// AUTHOR: Rob Tillaart
|
// AUTHOR: Rob Tillaart
|
||||||
// DATE: 30-okt-2017
|
// DATE: 30-okt-2017
|
||||||
// VERSION: 0.5.0
|
// VERSION: 0.5.1
|
||||||
// PURPOSE: Arduino library for RS485 modules
|
// PURPOSE: Arduino library for RS485 modules
|
||||||
// URL: https://github.com/RobTillaart/RS485
|
// URL: https://github.com/RobTillaart/RS485
|
||||||
|
|
||||||
@ -11,7 +11,7 @@
|
|||||||
#include "Arduino.h"
|
#include "Arduino.h"
|
||||||
#include "ASCII_CONTROL.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
|
class RS485 : public Stream
|
||||||
@ -54,12 +54,16 @@ public:
|
|||||||
size_t send(uint8_t receiverID, char msg[], uint8_t len);
|
size_t send(uint8_t receiverID, char msg[], uint8_t len);
|
||||||
bool receive(uint8_t &senderID, 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:
|
private:
|
||||||
Stream * _stream;
|
Stream * _stream;
|
||||||
uint8_t _sendPin = 0;
|
uint8_t _sendPin = 0;
|
||||||
uint8_t _deviceID = 0;
|
uint8_t _deviceID = 0;
|
||||||
uint16_t _microsPerByte = 1000;
|
uint16_t _microsPerByte = 1100;
|
||||||
|
|
||||||
// EXPERIMENTAL
|
// EXPERIMENTAL
|
||||||
uint8_t _bidx = 0;
|
uint8_t _bidx = 0;
|
||||||
|
@ -23,7 +23,7 @@
|
|||||||
const uint8_t sendPin = 4;
|
const uint8_t sendPin = 4;
|
||||||
const uint8_t deviceID = 0;
|
const uint8_t deviceID = 0;
|
||||||
|
|
||||||
SoftwareSerial SWS(6,7); // RX, TX
|
SoftwareSerial SWS(6, 7); // RX, TX
|
||||||
|
|
||||||
|
|
||||||
// use Software Serial
|
// use Software Serial
|
||||||
|
@ -6,6 +6,7 @@
|
|||||||
// minimal test to see how fast data can be send over the
|
// minimal test to see how fast data can be send over the
|
||||||
// RS485 bus at a given baud rate of 4800. (adjust if needed).
|
// RS485 bus at a given baud rate of 4800. (adjust if needed).
|
||||||
|
|
||||||
|
|
||||||
#include "Arduino.h"
|
#include "Arduino.h"
|
||||||
#include "RS485.h"
|
#include "RS485.h"
|
||||||
|
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/RobTillaart/RS485"
|
"url": "https://github.com/RobTillaart/RS485"
|
||||||
},
|
},
|
||||||
"version": "0.5.0",
|
"version": "0.5.1",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"frameworks": "*",
|
"frameworks": "*",
|
||||||
"platforms": "*",
|
"platforms": "*",
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
name=RS485
|
name=RS485
|
||||||
version=0.5.0
|
version=0.5.1
|
||||||
author=Rob Tillaart <rob.tillaart@gmail.com>
|
author=Rob Tillaart <rob.tillaart@gmail.com>
|
||||||
maintainer=Rob Tillaart <rob.tillaart@gmail.com>
|
maintainer=Rob Tillaart <rob.tillaart@gmail.com>
|
||||||
sentence=RS485 library for Arduino.
|
sentence=RS485 library for Arduino.
|
||||||
|
Loading…
Reference in New Issue
Block a user