SkypLabs / pyhdlcontroller

Python HDLC controller
https://pyhdlcontroller.skyplabs.net/en/stable/
MIT License
18 stars 1 forks source link

local variable 'seq_no' referenced before assignment #1

Closed dpolz closed 7 years ago

dpolz commented 7 years ago

In hdlcontroller.py line 260 seq_no is not defined. Must be defined before try-statement in line 229. Maybe seq_no=0

SkypLabs commented 7 years ago

Indeed, there is a problem here. However, the sequence number to send back as NACK must be the same as the one received in the frame which is processed. Defining it before the try-statement won't solve this issue.

After having re-read the code of python4yahdlc, I realised that I hadn't taken into account this case. The function get_data throws an FCSError exception without giving the sequence number to send back as NACK. Consequently, I have to update python4yahdlc first.

Thank you for having noticed that !

SkypLabs commented 7 years ago

I just added a test to bring this problem to light.

Actually, when a frame with an FCS error is received, two behaviours are possible :

After having fixed this issue, I will add an option to choose between these two behaviours.