473,410 Members | 1,873 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,410 software developers and data experts.

Python and USB/serial, weird errors

1
Dear All,

Two separate questions...

I am using pyUSB with python 2.5 and libusb-win32 version 0.1.12.1. My code is able to connect to my device (AT91SAM7X256) but is unable to do bulkwrites even though the bulkwrites are fine. I get a "usb_reap: timeout error". I tried to change the timeout to various values but still get that error. Has anyone experienced this before or knows what causes it and the solution to it?

I am using pySerial with python 2.5. I am reading a stream of data, 1 byte at a time and need to reverse and concatenate the bytes 2 bytes at a time. That is if i read in "FF 00 FF 00" the desired output is "00FF 00FF" which can later be converted to "255 255". I have a algorithm which works perfectly fine but what does not work is that the program never picks up 2D (45). The values before it and after it are picked up but 2D is missing. No matter what I make the timeout value, or the number of bytes I send to the computer from the AT91SAM7X256, pySerial never picks up 2D. The microcontroller is setup to run CDC communication with endpoint sizes of 64 bytes and a packet size of 1000 bytes. I do not believe that the problem lies with the microcontroller because I can see that the value 2D is comming through on the USB port with a port sniffer. Any ideas on what might be going on?

Thank you in advance,
JimmyC
Apr 13 '08 #1
2 3621
woooee
43
It sounds like the problem is with your code, but no one can tell unless you post it. When reading from a serial port, you use a flip-flop or switch, assuming that Null is sent between data bytes. This is a quick reply so I'm not 100% on the logic, but it shows the general idea. I have only used USPP for Python serial port access, so can't comment on PySerial. (And there seems to be a problem with the code tags??) [code]
flip_flop=1
while 1:
......data=read_data()
......if flip_flop and data:
...........## process data
...........flip_flop=0
......if not data and not flip_flop:
...........flip_flop=1 [/CODE}
Apr 16 '08 #2
jlm699
314 100+
(And there seems to be a problem with the code tags??)
Expand|Select|Wrap|Line Numbers
  1. flip_flop=1 
  2. while 1:    
  3. ......data=read_data()    
  4. ......if flip_flop and data:       
  5. ...........##   process data       
  6. ...........flip_flop=0    
  7. ......if not data and not flip_flop:       
  8. ...........flip_flop=1 
You kept the shift key held down when you closed your ']' bracket....
Apr 16 '08 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

11
by: dmbkiwi | last post by:
I am new to this group, and relatively new to python programming, however, have encountered a problem I just cannot solve through reading the documentation, and searching this group on google. I...
26
by: Wolfgang Keller | last post by:
Hello, is it that my know-how to use Google is insufficient or... ....does really noone use Python for industrial control applications? At least I didn't manage to find any publicly...
13
by: Brad Tilley | last post by:
A friend of mine wrote an algorithm that generates strings. He says that it's impossible to figure out exactly how the algorithm works. That may be true, but I think if I had enough sample strings...
3
by: carmen | last post by:
I'm working in an aplication for a Smart Device that need to "talk" with a printer continuosly through the serial port. I'm trying to use the John Hint's sample code "Use P/Invoke to develop a .NET...
26
by: Christoph Zwerschke | last post by:
You will often hear that for reasons of fault minimization, you should use a programming language with strict typing: http://turing.une.edu.au/~comp284/Lectures/Lecture_18/lecture/node1.html I...
852
by: Mark Tarver | last post by:
How do you compare Python to Lisp? What specific advantages do you think that one has over the other? Note I'm not a Python person and I have no axes to grind here. This is just a question for...
0
by: Kurt B. Kaiser | last post by:
Patch / Bug Summary ___________________ Patches : 342 open (-38) / 3712 closed (+54) / 4054 total (+16) Bugs : 951 open (-14) / 6588 closed (+33) / 7539 total (+19) RFE : 257 open...
13
by: John Dann | last post by:
A Python newbie, but some basic understanding of how classes, objects etc work in eg VB.Net. However, I'm struggling a little to translate this knowledge into the Python context. I'm trying to...
1
by: lutherchp | last post by:
A baffling end to my week! I open my serial port on my Debian PC (Debian version 5.0.1) I have a decent Null Modem lead going to another PC (I'll call it PC#2), with its port open with the same...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.