send raw data via serial

Please support our Python advertiser: Programming Forums - DaniWeb Sister Site
Reply   View First Unread View First Unread

Join Date: Oct 2006
Posts: 19
Reputation: MarkWalker84 is an unknown quantity at this point 
Solved Threads: 0
MarkWalker84 MarkWalker84 is offline Offline
Newbie Poster

send raw data via serial

 
0
  #1
Jan 23rd, 2007
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:
Reply With Quote Quick reply to this message  
Join Date: Oct 2006
Posts: 19
Reputation: MarkWalker84 is an unknown quantity at this point 
Solved Threads: 0
MarkWalker84 MarkWalker84 is offline Offline
Newbie Poster

Re: send raw data via serial

 
0
  #2
Jan 24th, 2007
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
Reply With Quote Quick reply to this message  
Join Date: Oct 2004
Posts: 4,145
Reputation: vegaseat is just really nice vegaseat is just really nice vegaseat is just really nice vegaseat is just really nice vegaseat is just really nice 
Solved Threads: 949
Moderator
vegaseat's Avatar
vegaseat vegaseat is offline Offline
DaniWeb's Hypocrite

Re: send raw data via serial

 
0
  #3
Jan 24th, 2007
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
May 'the Google' be with you!
Reply With Quote Quick reply to this message  
Join Date: Oct 2006
Posts: 19
Reputation: MarkWalker84 is an unknown quantity at this point 
Solved Threads: 0
MarkWalker84 MarkWalker84 is offline Offline
Newbie Poster

Re: send raw data via serial

 
0
  #4
Jan 24th, 2007
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
Reply With Quote Quick reply to this message  
Join Date: Jul 2006
Posts: 608
Reputation: jrcagle is on a distinguished road 
Solved Threads: 150
jrcagle jrcagle is offline Offline
Practically a Master Poster

Re: send raw data via serial

 
0
  #5
Jan 25th, 2007
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
Reply With Quote Quick reply to this message  
Join Date: Oct 2004
Posts: 4,145
Reputation: vegaseat is just really nice vegaseat is just really nice vegaseat is just really nice vegaseat is just really nice vegaseat is just really nice 
Solved Threads: 949
Moderator
vegaseat's Avatar
vegaseat vegaseat is offline Offline
DaniWeb's Hypocrite

Re: send raw data via serial

 
0
  #6
Jan 25th, 2007
Originally Posted by jrcagle View Post
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!
May 'the Google' be with you!
Reply With Quote Quick reply to this message  
Join Date: Oct 2006
Posts: 19
Reputation: MarkWalker84 is an unknown quantity at this point 
Solved Threads: 0
MarkWalker84 MarkWalker84 is offline Offline
Newbie Poster

Re: send raw data via serial

 
0
  #7
Jan 28th, 2007
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
Reply With Quote Quick reply to this message  
Join Date: Jan 2007
Posts: 3
Reputation: Jergosh is an unknown quantity at this point 
Solved Threads: 0
Jergosh Jergosh is offline Offline
Newbie Poster

Re: send raw data via serial

 
0
  #8
Jan 29th, 2007
Originally Posted by MarkWalker84 View Post
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
Reply With Quote Quick reply to this message  
Join Date: Jul 2005
Posts: 1,221
Reputation: bumsfeld will become famous soon enough bumsfeld will become famous soon enough 
Solved Threads: 138
bumsfeld's Avatar
bumsfeld bumsfeld is offline Offline
Nearly a Posting Virtuoso

Re: send raw data via serial

 
0
  #9
Jan 29th, 2007
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.
Reply With Quote Quick reply to this message  
Join Date: Oct 2006
Posts: 19
Reputation: MarkWalker84 is an unknown quantity at this point 
Solved Threads: 0
MarkWalker84 MarkWalker84 is offline Offline
Newbie Poster

Re: send raw data via serial

 
0
  #10
Jan 29th, 2007
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
Reply With Quote Quick reply to this message  
Reply

Message:



Similar Threads
Other Threads in the Python Forum


Views: 6871 | Replies: 11
Thread Tools Search this Thread



Tag cloud for Python
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC