943,942 Members | Top Members by Rank

Ad:
  • Python Discussion Thread
  • Unsolved
  • Views: 11251
  • Python RSS
You are currently viewing page 1 of this multi-page discussion thread
Jan 23rd, 2007
0

send raw data via serial

Expand Post »
Hi,

got a quick quickie...

Im trying to send commands to a micrcontroller via a USB->serial converter.

Im writing with wxPython on an XP machine it thats important.

I have been using the win32 module along with USPP and so far so good, apart from one thing. As far as i can work out it is only possible to write strings to the port as USPP uses a file handling style.

I am hoping to be able to send simple 8bit packets. I tried converting my data into the corresponding ASCII character and writing that to the port, but for anything lower than 0x20 it wont work as anything lower is an unprintable character...

Any help would be greatly appreciated.


Mark :mrgreen:
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
MarkWalker84 is offline Offline
19 posts
since Oct 2006
Jan 24th, 2007
0

Re: send raw data via serial

hmm... 20 views no replies...

Is this just a really difficult thing to do or have i missed something? done something wrong? i tried searching the forum but came up with nothing.

Thanks,


Mark
Reputation Points: 10
Solved Threads: 0
Newbie Poster
MarkWalker84 is offline Offline
19 posts
since Oct 2006
Jan 24th, 2007
0

Re: send raw data via serial

Mark, I think it is just a very specialized area. I did a lot of that kind of work in my earlier days using Delphi and the RS232 serial port. The modules (ADAM from Advantech Co., Ltd.) I used exchanged data as strings. It worked very well and was fun!

I trust you have taken a look at PyVisa:
http://pyvisa.sourceforge.net/
Last edited by vegaseat; Jan 24th, 2007 at 5:20 pm. Reason: info
Moderator
Reputation Points: 1333
Solved Threads: 1403
DaniWeb's Hypocrite
vegaseat is offline Offline
5,792 posts
since Oct 2004
Jan 24th, 2007
0

Re: send raw data via serial

I hadnt actually come across that before - i will dig around the siter and see what it unearths :-)

I feared this wasnt exactly a straight forward thing to do... never mind though - thats half the fun of programming :-)

Thanks for the link,


Mark
Reputation Points: 10
Solved Threads: 0
Newbie Poster
MarkWalker84 is offline Offline
19 posts
since Oct 2006
Jan 25th, 2007
0

Re: send raw data via serial

It almost seems like what you need is a simple C function to write the char to the port, and then link it in to your Python program.

Jeff
Reputation Points: 92
Solved Threads: 156
Practically a Master Poster
jrcagle is offline Offline
608 posts
since Jul 2006
Jan 25th, 2007
0

Re: send raw data via serial

Click to Expand / Collapse  Quote originally posted by jrcagle ...
It almost seems like what you need is a simple C function to write the char to the port, and then link it in to your Python program.

Jeff
If you use Windows XP forget that, you can only get to the ports using the designated driver. The days you could go directly to a port are long gone!
Moderator
Reputation Points: 1333
Solved Threads: 1403
DaniWeb's Hypocrite
vegaseat is offline Offline
5,792 posts
since Oct 2004
Jan 28th, 2007
0

Re: send raw data via serial

Yeah - i tried writing a program a few months back in VC++ which ultimately ended in failure when i realised it was near impossible to access serial / parallel ports with out some SERIOUS knowledge of kernals / drivers etc... much more than the basics...

I was under the impression that Python was a lot more user friendly in this aspect and so far i would have to agree... but its this one thing is really holding me up :-(

If it is possible to write a string to the port... why is it not possible to write an int, or hex value?? ARGH! lol


Mark
Reputation Points: 10
Solved Threads: 0
Newbie Poster
MarkWalker84 is offline Offline
19 posts
since Oct 2006
Jan 29th, 2007
0

Re: send raw data via serial

If it is possible to write a string to the port... why is it not possible to write an int, or hex value?? ARGH! lol
Wouldn't packing (http://docs.python.org/lib/module-struct.html) the data work for you?

Regards,
Greg
Reputation Points: 10
Solved Threads: 0
Newbie Poster
Jergosh is offline Offline
3 posts
since Jan 2007
Jan 29th, 2007
0

Re: send raw data via serial

Python has full set of binary operators, but I don't think there is one way to send bitstring to USB chip. Ultimately that is how data would travel in the serial wire.
Reputation Points: 404
Solved Threads: 180
Nearly a Posting Virtuoso
bumsfeld is offline Offline
1,422 posts
since Jul 2005
Jan 29th, 2007
0

Re: send raw data via serial

Its looking a lot like this cant be done...

So i think im going to have to do some sort of work around.

Just seems absolutely ridiculous to me that it is not possible to send binary / hex data to a serial port.


Mark
Reputation Points: 10
Solved Threads: 0
Newbie Poster
MarkWalker84 is offline Offline
19 posts
since Oct 2006
Message:
Previous Thread in Python Forum Timeline: python course- am i cheating here?
Next Thread in Python Forum Timeline: Newbie and easy question





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC