GithubHelp home page GithubHelp logo

serial-datagram's Introduction

Serial Datagram

Send datagrams over a serial link (byte stream).

Key features:

  • Detect transmission errors (using CRC-32)
  • "Hot-pluggable": automatically synchronizes with the data-stream by detecting the start of a new frame
  • Low overhead
  • No dynamic memory allocation

Protocol

A datagram frame looks like this:

[data][CRC32][END]

The CRC32 is the "Ethernet" CRC32 (polynomial 0x104C11DB7, inverted, initialized to 0) checksum of the (unescaped) data bytes transmitted MSByte first (big-endian).

The data and CRC32 fields are escaped such that an END byte is replaced by [ESC ESC_END] and an ESC byte is replaced by [ESC ESC_ESC].

Hex value Abbreviation Description
0xC0 END Datagram End
0xDB ESC Escape
0xDC ESC_END Transposed End
0xDD ESC_ESC Transposed Escape

serial-datagram's People

Contributors

stapelzeiger avatar antoinealb avatar msplr avatar

Stargazers

King Wong avatar cctsao1008 avatar Charles avatar  avatar

Watchers

James Cloos avatar  avatar Tsendrovskii Vladislav avatar  avatar

serial-datagram's Issues

call send function with length 0

I suggest not calling the send function in serial_datagram_send if the buffer length is zero.

for example here insert:

if (b - a > 0) {
    send_fn(sendarg, &dtgrm_byte[a], b - a);
}

Change signature of send callback

Currently the signature of the send callback is :

void (*send_fn)(void *arg, const void *p, size_t len);

Since the length is given in bytes, it would make more sense to give p such that sizeeof(*p) == 1. I suggest changing the type to :

void (*send_fn)(void *arg, const uint8_t *p, size_t len);

This is by no mean an emergency, but I think it would be neater.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.