SkoltechRobotics / rplidar

Python module for RPLidar A1 and A2 rangefinder scanners
MIT License
187 stars 126 forks source link

Incorrect descriptor starting bytes #7

Open jjehl opened 7 years ago

jjehl commented 7 years ago

After a iter_scans functions raise an Incorrect descriptor starting bytes.

Probably synchronization issue with the protocol

newpavlov commented 7 years ago

You need to call stop() after iter_scans(). Ideally it should be done automatically when iterator is not used any more. One way to solve it which I knew was to use with ... as, but I didn't like it much.

However after looking into this problem a bit more, it seems it can be solved elegantly by using "try finally" inside the iterator.

jjehl commented 7 years ago

if stop() is always needed, it could better to integrate the function in the iter_scans(). To make your code robust, it should support the eventuality that the users do things that you don't want. I have also problem after a reset() command because my A2 send a response message.

Anyway I work on improvements and I'll send you a first pull request this afternoon, we 'll be able to discuss on this base.

TeamMoscou commented 5 years ago

hello, I got the same error while using the iter_measurments() in a for loop. this for loop is used in a thread which is running with two others threads.

Masatoshi commented 3 years ago

HI When you got RPLidarException, you'd better to reconnect. If it does not exceed max retry, make it to connect again. In my case, it works.