Giter Club home page Giter Club logo

fredcom-arduino's Introduction


Arduino FredCom Library - Version 1.0.0 by Frederik Gelder [email protected]

Copyright 2016 Frederik Gelder

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.


Donation link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=B566VJ7BJWQGL

I made this library to make communication with the computer easier, as i had many issues with garbage bytes that were coming out of nowhere. This library uses COBS to encode the packages and a makeshift checksum to confirm validity of the package. each package also contains a len byte which is also used to validate the package.

a package consists of an opcode and its payload. opcodes >=250 are reserved.

for arduino: create a variable "FredCom<200,100> comms" to use the lib. 200 stands for receiveBufferSize and 100 for sendBufferSize. both can be in the range of 0-65535 and roughly determine the max size of the messages you can receive and send. the object will have to fit into your controllers memory, so dont choose higher numbers than needed at the moment it is hardcoded to use "Serial" for raw transmission. you have to initialize the serial interface yourself before you use the lib. call setup() on the object after that. you can receive messages when you set the function pointer "messageCallback" of the FredCom instance. it will give you the opcode and a RingQueueBuffer when a message is received. use the dequeue() and peekBottom() methods to get to your payload data. dequeue removed the byte from the buffer, while peekBottom just returns it. peekBottom also takes an index, so you can access all bytes in the buffer. invalid indices will return 0. use getContentLen() to check for the length of your payload. you have to call "loop" in your loop to receive messages. you can send messages with "sendMessage"

see examples for more info

for pc: create a FredCom variable. The Instance needs the portname and baudrate and will try to connect at instantiation. use the receiveMessage event to receive messages. it will give you the opcode of the message and a List of the payloads bytes. you dont have to call a loop() cause the instance creates its own thread for that. use sendMessage to send a message to the controller.

fredcom-arduino's People

Contributors

fredlllll avatar

Stargazers

Arttu Kuikka avatar thoro avatar Lewis B avatar Max Pleaner avatar

Watchers

James Cloos avatar  avatar thoro avatar

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.