BasicMicro - Forums

www.basicmicro.com
It is currently Sun May 20, 2012 11:40 pm

All times are UTC - 8 hours [ DST ]




Post new topic Reply to topic  [ 6 posts ] 
Author Message
 Post subject: String Input
PostPosted: Thu Oct 02, 2008 12:10 pm 
I am using an Atom to query another device. I am sending the following output:

SEROUT P15, I9600, ["AR60",0xD]

Then I expect a return string, from a SERIN, like "A3400". I need to strip off the "A" and convert the "3400" to a decimal numeric value. I have tried many things like:

SERIN P14, I9600, 200, DEAD, [skip 1, serstr]
SERIN P14, I9600, 10, DEAD, [dec serstr]

I just can't get it and the manual is sparse. Has anyone out there figured this out? Thanks.


Top
  
 
 Post subject: Re: String Input
PostPosted: Fri Oct 03, 2008 1:05 pm 
Offline
Master

Joined: Sun Aug 17, 2008 5:26 pm
Posts: 798
Location: CA bay Area
Hi, Cat. Try:
SERIN P14, I9600, 200, DEAD, [skip 1, DEC4 serstr]

After skipping the first character ("A"), we input ONLY the next four characters in decimal format.
If this doesn't give you the expected result, tell us what this DOES produce, or not do, or whatever.

Later!
kenjj

_________________
kenjj
http://blog.basicmicro.com/
http://kjennejohn.wordpress.com/


Top
 Profile  
 
 Post subject: Re: String Input
PostPosted: Mon Oct 06, 2008 5:26 am 
Thanks for the feedback. It still did not do the trick. I did neglect to mention that the input is terminated with a CR. Also, the length may be less than 4 digits. Apparently this is not straightforward with the Atom. I wrote this originally on a Basic Stamp and it worked perfectly as: SERIN 14, 84, 500, DEAD, [DEC serstr]. It always threw away the character and assigned the numeric value regardless of the length.

It seems to always jump to the "DEAD" routine without updating the "serstr" variable.


Top
  
 
 Post subject: Re: String Input
PostPosted: Mon Oct 06, 2008 4:55 pm 
Offline
Master

Joined: Sun Aug 17, 2008 5:26 pm
Posts: 798
Location: CA bay Area
OK, then try:
SERIN P14, I9600, 200, DEAD, [skip 1, DEC serstr]

I dropped the "4" from "DEC4". This should skip the first character, which you say is a letter, and input ASCII-CODED NUMBERS ONLY until the carriage return, the 13. That's any number of numbers up to the array limit. Any extra alphabetical character after the first one will terminate the input early. Thems the rules when you specify a modifier AS I UNDERSTAND THEM. Your only other recourse is to drop the "skip" portion, input the entire string until the carriage return comes along, then use a FOR-NEXT loop the size of your array to build a new string in which you drop alphabetical characters.

Try the suggested change above and let us know how it goes.
kenjj

_________________
kenjj
http://blog.basicmicro.com/
http://kjennejohn.wordpress.com/


Top
 Profile  
 
 Post subject: Re: String Input
PostPosted: Tue Oct 21, 2008 8:01 am 
I finally found the source of the problems. I bought an RS-232 to TTL adapter board from HVW and used ComTest Serial to simulate the serial input and used Serout to echo back what the Atom was getting. I discovered that when I removed the timeout, it behaved precisely as desired (like the Basic Stamp, dropping the leading character) just using the "dec serstr" format. When I put the timeout back in, it was only capturing the first digit, regardless of the modifiers. The problem was resolved when I placed a "clear" statement in the timeout routine. It only took a few minutes to resolve, once the problem was visible.

The reason for going with the interface and a terminal emulator rather than debug mode was that I had a lot of problems with the debugger in the latest version of the compiler (slow, crashing). Then, when I could see the data during normal running, it also became apparent that the debug mode was having difficulties handling the serial I/O and was adding additional problems. I think that the moral of the story is that it is a lot easier to fix problems when you know what they really are.


Top
  
 
 Post subject: Re: String Input
PostPosted: Tue Oct 21, 2008 9:45 am 
Offline
Master

Joined: Sun Aug 17, 2008 5:26 pm
Posts: 798
Location: CA bay Area
But, Cat, all the fun is in the chase!
I have tried applying DEBUG a couple of times in the last month on an Atom Pro Plus project, with miserable results. And yet the SFR report window helped me crack a bug (op error) last night.

While automated debugging and troubleshooting features are nice, I tend to use serial port/LCD output messages and toggling LEDs to get the job done. It has worked well for me so far.

Have a good project!
kenjj

_________________
kenjj
http://blog.basicmicro.com/
http://kjennejohn.wordpress.com/


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 6 posts ] 

All times are UTC - 8 hours [ DST ]


Who is online

Users browsing this forum: No registered users 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

Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group

phpBB SEO