simple serial interface (Solved)
Laurent R
Posts: 27
Hi
New day = > new problem
I try to put a flow of byte in a buffer using the simple serial interface and the max3430 for rs-485
It works when i send $AAFF13 or $AA13
But if i send more than 3 bytes it doesn't works ...
the way i receive
the way i send
Thanks for your help ...
Laurent
Post Edited (Laurent R) : 4/3/2009 7:55:21 AM GMT
New day = > new problem
I try to put a flow of byte in a buffer using the simple serial interface and the max3430 for rs-485
It works when i send $AAFF13 or $AA13
But if i send more than 3 bytes it doesn't works ...
VAR LONG Chan Byte Range Byte Bip Byte MyStr[noparse][[/noparse]1024]
the way i receive
ptr:=0 repeat while (MyStr[noparse][[/noparse]ptr]:=ser2.rx)<>$13 ptr++
the way i send
ptr2:=0 repeat ptr+1 ser2.tx(MyStr[noparse][[/noparse]ptr2]) ptr2++
Thanks for your help ...
Laurent
Post Edited (Laurent R) : 4/3/2009 7:55:21 AM GMT
spin
2K
Comments
the simple serial-object is much too simple to receive a lot of bytes
use the Serial Mirror-object from the obex
Inside this object it is easy to adjust the size of the receive and send-buffer
best regards
Stefan
SimpleSerial has a bug in the receive methode, maybe this cause your problems.
Here is an improved version of the rx methode. Only the marked line must be added.
Andy
I don't undersdand my problem because if i try to look after the CR caracter, it works for 3 Bytes transmission not more
But if I try this
the prop wait that I send 5 caracter and send me back so I know that he has received a CR caracter ..
Post Edited (Laurent R) : 4/1/2009 9:16:11 AM GMT
trying the serial-mirror object i can now receive and send a lot of bytes ... but there is a but, new bytes are always put at the end of my buffer...
with this code i through that new bytes should begin at MyStr[noparse][[/noparse]0] ... but it isn't.
As i initialize all my variable to 0 before doing a new reception i don't understand why old bytes aren't deleted when I receive a new reception ...
I'm confused so I still need help ...
Laurent
als long as your condition is (MyStr[noparse][[/noparse]ptr]:=ser2.rx)==$13
the condition stays FALSE when receiving a carriage return
only if you receive ASCII-Code 1*16+3 = 19 the condition will be TRUE
from your answer it is NOT clear if you made this change
your condition has to be
(MyStr[noparse][[/noparse]ptr]:=ser2.rx)==13 'WITHOUT the "$"
or (MyStr[noparse][[/noparse]ptr]:=ser2.rx)==$0D 'hexedcimal "0D" with the hexdecimal indicator "$"
If you use the serialmirrror-object and resize your receivebuffer to 1024 bytes or even 16384 bytes if you like
you just call ONCE rxstr and EVERYTHING IS DONE
why do you still want to walk on feet with programming a loop
if you can drive by car
using serial-mirror and coding just
best regards
Stefan
Thanks for your support...
In the serial-mirror i don't find a rxstr method... so I add it from extended serial object ...
But I have still the same problem...
I want to receive a serial command , do a task , send a serial answer and then be able to receive a new command...
The new command should replace the old and be saved in MyStr but it always saved after the first...
I can't erase the first one ...
Regards
Laurent
Just try to stop and restart the serial communication each time I want to receive a new command and it seems to be good [noparse]:)[/noparse]
thanks @ all
Laurent
Post Edited (Laurent R) : 4/2/2009 1:06:35 PM GMT
restart the serial communication that's shooting with canons on little birds
question: how many bytes are you receiving as ONE STRING as a maximum ?
I assumed from your original code MyStr[noparse][[/noparse]1024] that you receive up to 1024 bytes as ONE STRING
if your string-length is below 16 you can use the standard-objects
ANYWAY:
did you watch your incoming strings with a terminalsoftware ?
did you check with a terminalsoftware that your sending device is sending SINGLE commands ?
I have attached an archive with democode that works with PST.EXE as well as with brays terminal
using serial-mirror for receiving the string on Rx-Pin 26 and Tx-Pin 25
and send it to Rx-Pin 31, Tx-Pin 30
if you want to attach code use the archive-function of the propellertool
select your top-object-file (here main-test.spin) and then
cklick file - archive - project...
this creates a ZIP-file that contains ALL files needed to compile the whole project
best regards
Stefan
I don't have to kill little bird with canons now [noparse]:)[/noparse]
I think the bytefill command and the flush where the answer for me
Best regards
Laurent
i'm pretty new in the business with Propeller and Programming in general, but i created a little program in Spin, which creates several lines and shows it on my screen, it works really good.
But now, i want to read die angles of the lines (which i previously saved in 3 Variables) from a serial connection.
For the first it would be enough if i could send a value like "180" from a serial terminal to the propeller, the porgram reads it and saves it in a variable!
Now my questions:
1. Can i make a serial connection with the USB-Connection which is on the Starter-Kit-Board?
2. I've downloaded the serialmirror.spin, can i use this one?
3. Is there something like a tutorial which i can read for not asking you these (surely) stupid questions?
Thank you,
propwell
2) Yes, you should be able to use any of the serial I/O drivers to do this.
3) No. Do look at the FullDuplexSerial driver and the Extended FullDuplexSerial object. The latter includes routines for processing input numbers and strings.
In the future, please start your own thread. You'll get better and faster answers than hijacking someone else's thread.