Coder Social home page Coder Social logo

skyplabs / pyhdlcontroller Goto Github PK

View Code? Open in Web Editor NEW
17.0 4.0 1.0 99 KB

Python HDLC controller

Home Page: https://pyhdlcontroller.skyplabs.net/en/stable/

License: MIT License

Python 100.00%
python hdlc network network-communication controller embedded-systems embedded-linux python3

pyhdlcontroller's Introduction

Python HDLC Controller

PyPI Package Latest Release PyPI Package Downloads Per Month PyPI Package Python Versions Build Status Develop Branch Documentation Status

HDLC controller written in Python and based on the python4yahdlc Python module to encode and decode the HDLC frames.

Installation

From PyPI (recommended)

pip3 install --upgrade hdlcontroller

From sources

git clone https://github.com/SkypLabs/python-hdlc-controller.git
cd python-hdlc-controller
pip3 install --upgrade .

Documentation

The full documentation is available here.

License

MIT

pyhdlcontroller's People

Contributors

dependabot-preview[bot] avatar dependabot[bot] avatar skyplabs avatar

Stargazers

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

Watchers

 avatar  avatar  avatar  avatar

Forkers

srikanth26y

pyhdlcontroller's Issues

the controller is not working

Hi

I have setup a serial connection between two Linux machine and tried to communicate using this HDLC controller but sent message couldn't be received. The sender keeps trying to send the frame over and over again with no ACK signal from the receiver.

The code that I used is derived from your test with little additions. I am not sure why I could not get it to work. The code on both machines is this:

import threading, serial, time
from hdlcontroller.hdlcontroller import HDLController
from yahdlc import *

ser = serial.Serial(port = "/dev/ttyS0", baudrate = 9600, timeout = 0)

def read_serial():
    return ser.read(ser.in_waiting)

def send_callback(data):
    print('< {0}'.format(data))

def receive_callback(data):
    print('> {0}'.format(data))

hdlc_c = HDLController(read_serial, ser.write)
hdlc_c.set_send_callback(send_callback)
hdlc_c.set_receive_callback(receive_callback)
hdlc_c.start()

def readHDLC():
    while True:
        recvd = hdlc_c.get_data()
        print(recvd)

def writeHDLC():
    while True:
        strInput = input()
        hdlc_c.send(strInput)


readThread = threading.Thread(target=readHDLC)
writeThread = threading.Thread(target=writeHDLC)

readThread.start()
writeThread.start()

Best

Doesn't install in Windows

When trying to install in windows I get the following error:

ValueError: path '/home/travis/build/SkypLabs/python4yahdlc/lib/fcs16.c' cannot be absolute

HDLC on Ethernet port

Hi
Does your software make possible to receive data from HDLC frame on Linux on Ethernet port?

Example does not talk to ArduHDLC

What should read_uart return? Seems not to work with an bytearray like:
b'~Tst\xbe6~'

Which is the output of an arduino:

#include <Arduhdlc.h>

#define MAX_HDLC_FRAME_LENGTH 32
 
void send_character(uint8_t data);
void hdlc_command_router(const uint8_t *framebuffer, uint16_t framelength);
 
Arduhdlc hdlc(&send_character, &hdlc_command_router, MAX_HDLC_FRAME_LENGTH);
char framebuffer[MAX_HDLC_FRAME_LENGTH];
 
void send_character(uint8_t data) {
  Serial.print((char) data);
}

void hdlc_command_router(const uint8_t *framebuffer, uint16_t framelength) {
  // Do somethin here with the data in buffer
  return;
}

void setup() {
  Serial.begin(57600);
}

void loop() {
  framebuffer[0] = 'T';
  framebuffer[1] = 's';
  framebuffer[2] = 't';
  hdlc.frameDecode(framebuffer, 3);
  delay(500);
}

/*
SerialEvent occurs whenever a new data comes in the
hardware serial RX. This routine is run between each
time loop() runs, so using delay inside loop can delay
response. Multiple bytes of data may be available.
 */
void serialEvent() {
    while (Serial.available()) {
        // get the new byte:
        char inChar = (char) Serial.read();
        hdlc.charReceiver(inChar);
    }
}

If lib expects string: Not every bytearray can be decoded to a string, like example above. 0xbe can't be decoded

Splittig UART packages

Hi, wondering about when one HDLC frame is in two UART packages or if 2 HDLC frames are in 1 UART package. Should we implement splitting and concatenating UART packages (HDLC frames) ourself or should this be part of this library ?

In this example, I have to send the same frame twice as it is not recognized, because it is in 2 UART packages:

send data: b'~\xff\x10\x08\x01"!\x10\x00\x1a\x15\x08\x00\x10\x00\x18\x00"\x05extra*\x06gitrev"\x06\x08\x00\x10\x00\x18\x00\x1dU~' of len: 43
read data: b'~\xff\x01\x0e\xe1~~\xff\x10\x08\x01".\x10\x86' of len: 15
read data: b'\x12\x1a\x16\x08\x00\x10\x04\x18\x00"\x04-rc1*\x084354d098"\x11\x08\xb2\x80\xd0\x02\x10\xac\xc4\xaa\x93\x06\x18\xee\xd8\x91\xe3\x06\\\xa9~' of len: 47
send data: b'~\xff\x10\x08\x01"!\x10\x00\x1a\x15\x08\x00\x10\x00\x18\x00"\x05extra*\x06gitrev"\x06\x08\x00\x10\x00\x18\x00\x1dU~' of len: 43
read data: b'~\xff\x01\x0e\xe1~~' of len: 7
read data: b'\xff\x10\x08\x01".\x10\x86\x12\x1a\x16\x08\x00\x10\x04\x18\x00"\x04-rc1*\x084354d098"\x11\x08\xb2\x80\xd0\x02\x10\xac\xc4\xaa\x93\x06\x18\xee\xd8\x91\xe3\x06\\\xa9~' of len: 55
send data: b'~\xff!\x0c\xc0~' of len: 6

question: Does your controller handles SREJ frames?

Hello guys,

First of all, let me thank you for your work. It is nice to see initiatives like yours.
I have a situation where a series of frames are sent with segmented data in another layer.
One of these frames is rejected and a SREJ is sent back to me.
I would like to know if your controller handles SREJ and does re-transmission automatically.

BR,

Roberto

Problem with instalation

Hello,

First, thanks for share your proyect. I will try to test but the instalation has a problem.

image

I do teh upgrade of the setuptools and wheel, but I can't solve this problem, Could you help me please?

Thanks
Juan Carlos

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.