mirror of
https://github.com/RobTillaart/Arduino.git
synced 2024-10-03 18:09:02 -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/).
|
||||
|
||||
|
||||
## [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.
|
||||
|
@ -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
|
||||
|
||||
|
@ -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.
|
||||
}
|
||||
|
||||
|
||||
|
@ -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
|
||||
@ -47,19 +47,23 @@ public:
|
||||
// send ASCII encoded messages from one master to multiple clients.
|
||||
// msg[] = 32..127
|
||||
// len = 1.. 48 (internal receive buffer is 50)
|
||||
size_t send(uint8_t receiverID, uint8_t msg[], uint8_t len);
|
||||
bool receive(uint8_t &senderID, uint8_t msg[], uint8_t &len);
|
||||
size_t send(uint8_t receiverID, uint8_t msg[], uint8_t len);
|
||||
bool receive(uint8_t &senderID, uint8_t msg[], uint8_t &len);
|
||||
|
||||
// EXPERIMENTAL
|
||||
size_t send(uint8_t receiverID, char msg[], uint8_t len);
|
||||
bool receive(uint8_t &senderID, 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);
|
||||
|
||||
// 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;
|
||||
|
@ -23,7 +23,7 @@
|
||||
const uint8_t sendPin = 4;
|
||||
const uint8_t deviceID = 0;
|
||||
|
||||
SoftwareSerial SWS(6,7); // RX, TX
|
||||
SoftwareSerial SWS(6, 7); // RX, TX
|
||||
|
||||
|
||||
// use Software Serial
|
||||
|
@ -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"
|
||||
|
||||
|
@ -73,7 +73,7 @@ void loop()
|
||||
|
||||
int x = rs485.read();
|
||||
|
||||
// HEX DUMP PART
|
||||
// HEX DUMP PART
|
||||
if (x < 0x10) Serial.print('0');
|
||||
Serial.print(x, HEX);
|
||||
Serial.print(" ");
|
||||
|
@ -15,7 +15,7 @@
|
||||
"type": "git",
|
||||
"url": "https://github.com/RobTillaart/RS485"
|
||||
},
|
||||
"version": "0.5.0",
|
||||
"version": "0.5.1",
|
||||
"license": "MIT",
|
||||
"frameworks": "*",
|
||||
"platforms": "*",
|
||||
|
@ -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.
|
||||
|
Loading…
Reference in New Issue
Block a user