Discussion forum for the BasicX family of microcontroller chips.
get bytes from com ... until special character - spatial_klode - Nov 6 12:29:50 2007
Hi guys,
I'm new about BX24P. But I've realized a little software that it can
get a fixed number of bytes from COM1, extracts some information and
generates a new byte array that it sends through COM3.
Now, really it cannot get a fixed number of byte, but it must get all
bytes from COM1 until it receive a special chars (for example, "X" 88
decimal).
Now I'll show you a portion of the code:
=================================================
[...]
dim q_in(1 to 10) as byte
dim q_out(1 to 10) as byte
dim cmd_in_buffer(1 to 160) as byte
dim cmd_out_buffer(1 to 160) as byte
call OpenQueue(q_in,10)
call OpenQueue(q_out,10)
call OpenCom(1,9600,q_in,q_out)
Do
call GetQueue(q_in,cmd_in_buffer(i),1)
i = i+1
Loop While i < 127
[...]
=================================================
In this case, it works great. It takes a "string" (as byte array), and
count the number of chars... while i < 127.
But if I want to get the string until the last char is "X"?
For example:
=================================================
[...]
Do
call GetQueue(q_in,cmd_in_buffer(i),1)
i = i+1
Loop While cmd_in_buffer(i-1) <> 88
[...]
=================================================
In this case it not works. It spend more time for the last control, so
it losts many chars.
Do you have any suggestions???

(You need to be a member of basicx -- send a blank email to basicx-subscribe@yahoogroups.com )
RE: get bytes from com ... until special character - Fabrizio Sellone - Nov 7 23:18:39 2007
Hi. I am not sure I have got it right, but if the problem is the time taken to check for
inequality
while cmd_in_buffer(i-1) <> 88
why not trying to replace this line of code with equivalent statements (this is a weak
proposal ... I know ...) ? such as
until cmd_in_buffer(i-1) = 88
or
while cmd_in_buffer(i-1) - 88
Would that solve the problem ?
Who knows ? Maybe you will be lucky and these statements will take less time to be
executed ... It really depends on how the <> instruction is coded ...Regards
Fabrizio
To: b...@yahoogroups.comFrom: k...@inwind.itDate: Tue, 6 Nov 2007 15:12:32 +0000Subject:
[BasicX] get bytes from com ... until special character
Hi guys,I'm new about BX24P. But I've realized a little software that it canget a fixed
number of bytes from COM1, extracts some information andgenerates a new byte array that it
sends through COM3.Now, really it cannot get a fixed number of byte, but it must get
allbytes from COM1 until it receive a special chars (for example, "X" 88decimal).Now I'll
show you a portion of the code:=================================================[...]dim
q_in(1 to 10) as bytedim q_out(1 to 10) as bytedim cmd_in_buffer(1 to 160) as bytedim
cmd_out_buffer(1 to 160) as bytecall OpenQueue(q_in,10)call OpenQueue(q_out,10)call
OpenCom(1,9600,q_in,q_out)Docall GetQueue(q_in,cmd_in_buffer(i),1)i = i+1Loop While i <
127[...]=================================================In this case, it works great. It
takes a "string" (as byte array), andcount the number of chars... while i < 127.But if I
want to get the string until the last char is "X"?For
example:=================================================[...]Docall
GetQueue(q_in,cmd_in_buffer(i),1)i = i+1Loop While cmd_in_buffer(i-1) <>
88[...]=================================================In this case it not works. It
spend more time for the last control, soit losts many chars.Do you have any
suggestions???
_________________________________________________________________
Scarica GRATIS le emoticon della tua squadra del cuore e il calendario di serie A!
http://www.emoticons-livemessenger.com/pages/msnitcalcio/index.htm
[Non-text portions of this message have been removed]

(You need to be a member of basicx -- send a blank email to basicx-subscribe@yahoogroups.com )
RE: get bytes from com ... until special character - Fabrizio Sellone - Nov 8 6:36:49 2007
Here is a weak proposal .... but if you are lucky enough it can even make your point
...
How about replacing the time consuming statement
while cmd_in_buffer(i-1) <> 88
with others like
until cmd_in_buffer(i-1) = 88
or
while cmd_in_buffer(i-1) - 88
Regards,
Fabrizio
To: b...@yahoogroups.comFrom: g...@rightime.comDate: Tue, 6 Nov 2007 11:21:42
-0500Subject: Re: [BasicX] get bytes from com ... until special character
> dim cmd_in_buffer(1 to 160) as byte> dim cmd_out_buffer(1 to 160) as byte> Perhaps
you've exhausted the stack. Is it necessary for these buffers to be this large? The BX-24
has 401 bytes of available RAM; you've used 320 of that for these variables. That leaves
81 bytes for the system stack and other variables. Depending on your code, that might be
insufficient.Try decreasing the 320-byte buffer lengths to perhaps find more
success.Tom
_________________________________________________________________
Scarica GRATIS la versione personalizzata MSN di Internet Explorer 7!
http://optimizedie7.msn.com/default.aspx?mkt=it-it
[Non-text portions of this message have been removed]

(You need to be a member of basicx -- send a blank email to basicx-subscribe@yahoogroups.com )