It is currently Thu Apr 24, 2014 10:35 pm




Post new topic Reply to topic  [ 3 posts ] 
 Serial Port Question 
Author Message
Captain
Captain

Joined: Thu Jun 28, 2012 5:59 am
Posts: 89
Post Serial Port Question
I am doing some testing with the new serial port module. It is a little function that just reads incoming data. When it is reading it translates what I am sending (a, b, hello, etc.) into the ascii characters when I use readUntil() eg. "b" would read as 98. Using the readBytes() function will read "Yg==".

essentially:

textByte = readBytes(port2, 1)
textUntil = readUntil(port2, "," 0)
system.tag.writeToTag("Byte", textByte) # YQ==
system.tag.writeToTag("Text", textUntil) # 97


Python uses chr("numbers") to translate from ascii to text and there is another utility bas64.base64("numbers") to translate from base64. Neither of these seem to work for me, but I am new to Python and could very well be missing a step.

any suggestions?

Thanks!


Fri Jul 13, 2012 7:32 am
Profile
Moderator
Moderator

Joined: Mon Oct 27, 2008 4:10 pm
Posts: 1906
Location: Folsom, CA
Post Re: Serial Port Question
I seem to have missed the question in here, I think. Are you trying to convert the byte you read into a string?

_________________
Kevin Herron
Software Developer
Inductive Automation


Fri Jul 13, 2012 7:40 am
Profile WWW
Moderator
Moderator

Joined: Mon Oct 27, 2008 4:10 pm
Posts: 1906
Location: Folsom, CA
Post Re: Serial Port Question
Ok, actually I think I see the problem with readUntil(). I'll have to fix this for the next release.

_________________
Kevin Herron
Software Developer
Inductive Automation


Fri Jul 13, 2012 8:04 am
Profile WWW
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 


Who is online

Users browsing this forum: Google [Bot] and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to: