Coder Social home page Coder Social logo

araffin / arduino-robust-serial Goto Github PK

View Code? Open in Web Editor NEW
132.0 7.0 28.0 15 KB

A simple and robust serial communication protocol. It was designed for Arduino but can be used for other purposes (e.g. bluetooth, sockets). Implementation in C Arduino, C++, Python and Rust.

Home Page: https://medium.com/@araffin/simple-and-robust-computer-arduino-serial-communication-f91b95596788

License: MIT License

Makefile 26.27% C 27.69% C++ 46.04%
arduino raspberry-pi serial communication protocol cpp c python rust bluetooth

arduino-robust-serial's People

Contributors

araffin avatar eldering avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

arduino-robust-serial's Issues

How to compile this?

When I open it in Arduino IDE as described here:
chrome_DUt5v9XLFQ

I get this error when I try to upload:
javaw_BJRAq1dhM3

I'm on Windows 10 x64. As I understand, this solution was developed on Linux. I don't understand how do I port all this to Windows. Sudo, yml, atp-get, CMake, Makefile, gcc compiler. I don't know these. Any suggestions how to make it all work on Windows?

C++ Implementation not communicating

I'm having a problem running code from the C++ implementation.

I copied robust_serial.hpp to my project and implemented a class to read and write information to the serial port using std::fstream.

std::fstream serial_port;
serial_port.open(device, ios::in|ios::out|ios::app|ios::binary);
write_order(serial_port, SEND);
write_i32(serial_port, id);

The implementation in my arduino is like that:

setup() {
    Serial.begin(SERIAL_BAUD);
}

loop() {
    if(Serial.available() > 0)
    {
        Order order_received = read_order();
        switch(order_received)
        {
            case SEND:
                 uint32_t ID = (uint32_t) read_i32();
        }
    }
}

So I adjust the stty from the terminal:
stty 115200 -F /dev/ttyACM0

But the data is not arriving to the arduino board, but i noticed that if I use a sniffer like interceptty like that:
interceptty /dev/ttyACM0

That create a bind to the /dev/pts/3, and if I connect to that port the data is Ok and is arriving to arduino. But if I remove the interceptty and connect direct to the /dev/ttyACM0 it stop working again. And if I start interceptty and kept it running I can communicate either, even with the /dev/ttyACM0 port.

What could be intercepting my communication with the board?

Serial latency?

Hello,

I'm curious to know what kind of latency you were getting and with which arduino?

I'm using a similar technique to try and communicate with my rotary inverted pendulum but I'm running into latency issues. It's taking a long time to send the command and get back an answer from the arduino. To be clear I'm not using this specific library but my code is really close.

Using an arduino nano it takes me 15.5 ms to send and then receive 8 bytes from pyserial. Using a nano every it is much faster and takes only 1.5 ms. I'm trying to investigate what's affecting the speed and to figure out if I've made a mistake somewhere.

Cheers

Communication between PC and Robohat MM1 Circuit python

do you think, it is possible to use your robust-serial protocol between PC (linux, python3) and Robohat MM1 (CircuitPython) ?

I'm searching for a robust and flexible way to talk to Circuit Python targets (ROS and Donkeys) :-)

Issue with digitalRead

``Hello everyone, i'm currently having issue with the digitalRead function, i explain the problem:
basically i have an Order that is TOUCH_L that is sended from a Raspberry Pi 3 B+ to an Arduino Uno connected together by a USB wire; as soon as the command is recieved from arduino, i use the digitalRead(pinNumber) function to read the state of a touch sensor.

Raspberry code:

 while True:
        write_order(serial_file, Order.TOUCH_L)
        print(read_order(serial_file))
        print(read_i8(serial_file))

Arduino Code:

switch(order_received)
      {
        case TOUCH_L:{      
          write_order(TOUCH_L);
          if(digitalRead(yl99_l_pin)==LOW){
            write_i8(1); 
          }
          else{
            write_i8(0);
          }
          break;
        }
        ....

ISSUE: the print_order looks to be not syncronized with the arduino becouse the output is the following:
Order.TOUCH_L
0
Order.HELLO
1
Order.HELLO
0
Order.TOUCH_L
0
Order.HELLO
1
......

Note that the 0/1 after each order printed doesn't looks to be the sensor state because it should have been always 0 given that i was not triggering the sensor, this means that the 1 observed is the TOUCH_L value which is being read as value (expected the first one that i guess is correct, both the order and the sensor value are correct)

Thanks in advance for the help!

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.