Comments (6)
It's a good idea, I'm only concerned about back compat. If you add it, please make it configurable, so it can be switched off.
from tinyframe.
@grantramsay Sounds reasonable to me, this resyncing will work. I'd gladly merge that.
(I don't currently use TF in any active project, so I don't see implementing this myself soon..)
from tinyframe.
That would actually be quite an elegant solution, I might try implementing that
from tinyframe.
I might be missing something, but wouldn't a simple back compatible way be to:
- buffer entire packet when receiving, need to increase buffer size to handle full packet (header + payload + checksum/crc)
- if checksum/crc fails or
len > TF_MAX_PAYLOAD
, memmove buffer to next SOF (if present) and reset rx index
This way the state machine will resynchronise on the next valid checksum/crc with no change to the message structure
Edit:
Also TF_ResetParser
would reset the rx index, so reliable links without checksum/crc (e.g. TCP) could call it to resync if connection is restarted.
Additionally a timeout could be added to move to the next SOF. For the case where the link fails with a large but not invalid message length, and the next message is short. The state machine would need to receive extra rx data to resync, which may not be timely enough for the application
from tinyframe.
@mon - I had a little go at this the other day.
It got a little more complicated than I'd like, but there might be something helpful here (definitely a "work in progress"):
master...grantramsay:wip/feat-16/sof-resync
from tinyframe.
Hmmm, certainly a little more complex than I expected. I'll experiment a bit over the next few weeks and see how reliable it is.
from tinyframe.
Related Issues (20)
- Update readme
- Allow custom CRC functions
- Add optional error reporting
- Add notes to the README about TF_Accept HOT 5
- Optional device address fields
- java implemen?? HOT 1
- add macro t calculat overal overhead size HOT 2
- multiple instances with different frame structure? HOT 3
- A demo of using the Payloadparser HOT 2
- TF_CKSUM_NONE can lead to memory corruption if RX message too large HOT 2
- if TF_CKSUM_NONE is used, we can use memcpy instead of single byte copy loop
- ,
- Maybe should add some ack mechanism HOT 1
- tinyframe-js HOT 4
- TODO: void ** attribute in listeners and send funcs for data passing to listeners
- TODO: Built-in timeout for ID listeners with timed-out callback
- Replace the look-up table CRC's with an algorithm HOT 3
- Make TinyFrame reentrant / support multiple instances
- Don't call listeners with NULL data for clean-up after self-close with TF_CLOSE
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from tinyframe.