GithubHelp home page GithubHelp logo

oscup's Introduction

Hi 👋, I'm Daniel

PhD Candidate in ICT at Università degli Studi di Modena e Reggio Emilia


projectoofficial

projectoofficial

I share code, projects and lessons under the name Projecto. My main aim is to share knowledge; it all started randomly when I opened a YouTube Channel in 2016 with a school colleague! I am still a university student, and this means that I am looking forward to share with all of you what I learn there.

More Info

  • 🔭 I’m currently doing research on Computer Vision and AI for embedded systems

  • 🌱 I’m currently learning pyTorch, Torchvision, onnx

  • 🤝 I’m looking for help with OSCUP

  • 📫 How to reach me [email protected]


On this GitHub profile you can find code about

  • instagram bot
  • A.I. algorithms
  • STM32 example code
  • Arduino example code
  • ESP32 example code
  • OSCUP: Open Source Custom UART Protocol (consider supporting it!)
  • FiremanSam (Fire detector using A.I.)
  • ComputerVisionProject: AI for automotive things

Languages and Tools

arduino bash c cplusplus flask git java linux opencv pandas python pytorch scikit_learn seaborn tensorflow

Let's keep in contact!

onedeadmatch 19266935 ucik8jm7gbihceun-ag_8kag


🔥 My Stats :

OSCUP

Oscup is an open source custom UART protocol. It is written in C and allows two microcontrollers (ESP32 for now) to share data within a specified payload. Each packet sent and received contains information about the payload length, the command associated to the payload sent and an ID for the microcontroller which sent the message. It also include CRC to check wether a packet is corrupted or not. Oscup also manages ACKs and NACKs, sending again the packet if it was corrupted for example.

For shure it contains lots of bugs, we've written a python library which allows also computers to use OSCUP for communicating with microcontrollers, and we would like to extend it more! Any idea? Open an issue and help us improving it!

If you like the Idea, just Star the project! :)

Where you can find me 🔎

Contacts 📫

YouTube Collaborations: Send us an e-mail

Contact Daniel: write to Daniel

Note

All the software provided on this GitHub page has been written and is maintained by Dott. Daniel Rossi

oscup's People

Contributors

antimoad avatar projectoofficial avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Forkers

cochan2628

oscup's Issues

Error 6: CRC_ERROR

Hi, I am trying to communicate 2 ESP32 and I am getting always ERROR 6: CRC_ERROR.
I am trying the DemoRead and DemoWrite examples but I modified it in order to print on Serial.
In oscup.h the unique modifications I did was change the UART_PORT to 1 and change RX AND TX to 26 and 27. (And 27 and 26 in the other ESP32).

What causes that error? And how can I solve it?
On each ESP32 the ID should be different?
Thank you.

#include "Arduino.h"
#include <stdlib.h>
#include "Oscup.h"

uint8_t id = 0x4D;

//constructor takes device's ID and baudrate
Oscup oscup = Oscup(id);

char *uint64_toBytes(uint64_t number) {
  /*@brief converts a uint64_t into a char * pointer
     @param number uint64_t you want to convert
     @return the pointer containing the new array of chars
  */
  size_t dim = sizeof(uint64_t);
  char *buff = (char *)calloc(dim, sizeof(char));
  for (int i = 0 ; i < dim; i++) {
    buff[i] = (number >> (8 * i)) & 0xFF;
  }
  return buff;
}

void setup() {
  //it is mandatory to call begin() for starting UART
  Serial.begin(115200);
  oscup.begin(115200);
}

unsigned long wait_time = millis();

void loop() {
  //this function returns the APB clock frequency (set inside ESP32 libraries)
  uint64_t tim = oscup.get_APB_clk();

  //convert uint64_t to byte array
  char *arr2 = uint64_toBytes(tim);

  //write the packet, parameters: command(uint8_t), length of the payload(uint8_t), payload(char *)
  uint8_t error = oscup.write((uint8_t)TxCommands::SHARE, sizeof(uint64_t), arr2);
  Serial.print("Error: ");
  Serial.println(error);
  //remember always to free dangling pointers!
  free(arr2);
  delay(2000);
}
#include "Arduino.h"
#include <stdlib.h>
#include "Oscup.h"

uint8_t id = 0x5D;

//constructor takes device's ID and baudrate
Oscup oscup = Oscup(id);

char *uint64_toBytes(uint64_t number) {
  /*@brief converts a uint64_t into a char * pointer
     @param number uint64_t you want to convert
     @return the pointer containing the new array of chars
  */
  size_t dim = sizeof(uint64_t);
  char *buff = (char *)calloc(dim, sizeof(char));
  for (int i = 0 ; i < dim; i++) {
    buff[i] = (number >> (8 * i)) & 0xFF;
  }
  return buff;
}

void setup() {
  Serial.begin(115200);
  //it is mandatory to call begin() for starting UART
  oscup.begin(115200);
}

unsigned long start_time = millis();

void loop() {
  packet_t packet;
  uint8_t errore = 255;

  start_time = millis();
  while (errore != (uint8_t)ErrorCodes::OK && millis() - start_time < 200) {
    errore = oscup.read(&packet);
  }

  delay(5);
  Serial.println("Error:");
  Serial.println(errore);
  if (errore != (uint8_t)ErrorCodes::OK) {
    uint64_t err = errore;
    char *arr3 = uint64_toBytes(err);
    oscup.write((uint8_t)0x03, sizeof(uint64_t), arr3);
  } else {
    if (packet.length == 0) {
      String str = "empty";
      Serial.println("Aqui");
      oscup.write((uint8_t)TxCommands::SHARE, str.length() , (char *)str.c_str());
    } else {
      uint64_t l = packet.length;
      char *arr2 = uint64_toBytes(l);
      Serial.println("llega");
      Serial.println(arr2);
      oscup.write((uint8_t)TxCommands::CONFIRM, packet.length, packet.payload);
    }
  }
  delay(1000);
}

ESP32 - ESP32 communication for sending file from A to B

Hi,

First of all, I really am into the idea of this package, I was trying to make my own implementation, but I don't have enough C++ knowledge to do so...

Anyhow, I tested the examples and keep getting the issue on the Oscup oscup = Oscup(0x5D, UART_NUM_2, RX_PIN, TX_PIN); initialization, that it crashes on 'uart_port_t' is not a class, namespace, or enumeration in Oscup/oscup.h:101:59.

I have tried to implement this furter, but I don't know if it's good what I'm currently doing, because of the error.

My current situation:

I already have a Serial connection between the UART_2 (Serial1) of the ESP32.

I have there a really basic "protocol" implemented and I don't really want to re-write the whole thing.

My sender implementation:

#include <Arduino.h>
#include "oscup.h"

Oscup oscup = Oscup(0x5D, UART_NUM_2, 39, 23);

void setup() {
     Serial1.begin(115200, SERIAL_8N1, 39, 23); // ESP 2 ESP comm
    oscup.begin(115200);
}

void loop() {
    File file = LittleFS.open("/newFirmware.bin"); // this file exists
    uint8_t buffer[64];
    
    int bytesRead = file.read(buffer, sizeof(buffer));
    
    if (bytesRead > 0) {
        oscup.write((uint8_t)TxCommands::SHARE, sizeof(buffer), (char*) buffer);
    } else {
        file.close();
    }
}

The receiver side:

#include <Arduino.h>
#include "oscup.h"

Oscup oscup = Oscup(0x5D, UART_NUM_2, 39, 23);

void setup() {
     Serial1.begin(115200, SERIAL_8N1, 39, 23); // ESP 2 ESP comm
    oscup.begin(115200);
}

void loop() {
    packet_t packet;
    uint8_t errore = 255;
    
    start_time = millis();
    
    while (errore != (uint8_t)ErrorCodes::OK && millis() - start_time < 200) {
        errore = oscup.read(&packet);
    }
    
    delay(5);
    
    if (errore != (uint8_t)ErrorCodes::OK) {
    
        Serial.print("Error: ");
        Serial.println(errore);
    
    } else {
        if (packet.length == 0) {
            Serial.println("empty packet");
        } else {
            newFirmwareFile.write(packet.payload, packet.length)
        }
    }
    

}

Am I missing something here?

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.