Serial Comms - The first tenative steps - can someone point the noob in the cor
pacman
Posts: 327
I have a rs232 serial device I want to communicate with.
Unfortunately this device is bit of a special beast, and I'm struggling with actually establishing reliable communications.
To establish communications the prop needs to send "ZA1". OK so far.
The other device can take up to three seconds to respond with a "^", but the manufacturer suggests that if i haven't got a response back in 1 second I should send "ZA1" again. This means that the other unit will occasionally wake-up and send one "^" for every ZA1 I sent.
So, If I'm using the FullDuplexSerial object (is that the best ? option), then I rxcheck and if no char then send again, if "rxcheck" is any value other then 0 then should I use "rx" ? What happens if the remote device woke up, decided to respond to a couple of ZA1's, sent several ^'s and I'm not calling 'rx' fast enough?
Then just to add insult to injury, once the unit has done it's first response to ZA1, I need to repeat the whole procedure with ZE1 (with the same sort of timing considerations}.
Does someone ALREADY have some code that is 'sort of' what I need to do and could share with me? It would be real good if it came with some comments so as I could dissect and LEARN.
Thanks heaps in advance.
Paul
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
=================
The future is in our hands.
Which way to the future?
=================
Unfortunately this device is bit of a special beast, and I'm struggling with actually establishing reliable communications.
To establish communications the prop needs to send "ZA1". OK so far.
The other device can take up to three seconds to respond with a "^", but the manufacturer suggests that if i haven't got a response back in 1 second I should send "ZA1" again. This means that the other unit will occasionally wake-up and send one "^" for every ZA1 I sent.
So, If I'm using the FullDuplexSerial object (is that the best ? option), then I rxcheck and if no char then send again, if "rxcheck" is any value other then 0 then should I use "rx" ? What happens if the remote device woke up, decided to respond to a couple of ZA1's, sent several ^'s and I'm not calling 'rx' fast enough?
Then just to add insult to injury, once the unit has done it's first response to ZA1, I need to repeat the whole procedure with ZE1 (with the same sort of timing considerations}.
Does someone ALREADY have some code that is 'sort of' what I need to do and could share with me? It would be real good if it came with some comments so as I could dissect and LEARN.
Thanks heaps in advance.
Paul
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
=================
The future is in our hands.
Which way to the future?
=================
Comments
Suggest you also echo the characters you tx and rx to the PC using a teminal program such as PropTerm for debugging purposes. Just use 115200 and you should have no problems in seeing what is happening.
If you look at the TriBlade threa
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Links to other interesting threads:
· Home of the MultiBladeProps: TriBlade,·RamBlade,·SixBlade, website
· Single Board Computer:·3 Propeller ICs·and a·TriBladeProp board (ZiCog Z80 Emulator)
· Prop Tools under Development or Completed (Index)
· Emulators: CPUs Z80 etc; Micros Altair etc;· Terminals·VT100 etc; (Index) ZiCog (Z80) , MoCog (6809)
· Search the Propeller forums·(uses advanced Google search)
My cruising website is: ·www.bluemagic.biz·· MultiBladeProp is: www.bluemagic.biz/cluso.htm
see attached zip-archive with a demo.
Play around with it. And come back with all the questions you have
best regards
Stefan
thanks for that, my basic code sort of looked similar (but without the DAT section - I likey).
If I'm understanding the FDX+ object correctly {and there is every chance I'm not}, then doesn't your code only send one instance of ZA1. I was thinking I could reduce the time to 1000, and then have a loop counter (x strikes and give a "serious error" message).
and should the line "Char := Debug.rxtime(3000)" _really_ be pointing to Debug? I would have thought it should be pointing to Serial, but there might be some other reason that I'm missing...
And thanks for help so-far..
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
=================
The future is in our hands.
Which way to the future?
=================
think more positive about your abilities !
Oops your right !! Of course Char := Debug.rxtime(3000) hast to be Char := Serial.rxtime(3000)
I'm not sure what you mean with one instance. An instance in programming means there is one copy of a datastructure stored to memory doing whatever it does
There is a repeat-loop that makes the whole thing repeat endlessly
Of course you can have a loopcounter that does 3 or 5 trys and then sends a error-message that you designed to whatever it is
You can reduce the timeout as I have said play around with the code to get familiar with it
If you like attach a TXT-file of the output you get in PST.EXE to a posting that I can see what you get.
best regards
Stefan
Thanks, I've successfully got my object sending ZA1 and waiting 1 second for a response.
My initial test was sending to hyperterm and then me trying to type a ^ as a return.
The net effect is that it appears that my USB/serial adaptor isn't transmitting (or my hyper-terminal settings are massively wrong) as no matter what I typed on the PC I got no response on the prop other than timeout.
As a 'final' test I directly connected the prop output TX pin to the RX pin and - lo and behold- the data transmitted was what I was receiving... (who'd of thunk that ).
So now I've got to pick-up a new usb/serial converter to try and figure-out where I was going wrong (hyperterminal or cable)....
And thanks again for your help so far...
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
=================
The future is in our hands.
Which way to the future?
=================
Hmm perhaps that was what I was doing wrong... (never mind, I needed a few new usb/232 adaptors anyway - I seem to be forever forgetting what the one I have is currently attached too).
I was using the PST for the debug port, and hyperterm as the 'real device'. I wonder if you can run two versions of PST?
What is this Teamwork of which you speak? - I've googled (and had a bit of sniff about in the archives, but I can't find it) - perhaps you can supply a link?
Or perhaps you can offer suggestions as to a better (and ideally free) terminal program {windows} to use as the 'real device'.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
=================
The future is in our hands.
Which way to the future?
=================
I got some new USB/serial adaptors today and they work - and my code works. Now that I have successfully got step 0.2 working, I can move on.
So HUGE thanks to all who helped.
Tip for young players... Use working hardware when testing your designs - it helps.....
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
=================
The future is in our hands.
Which way to the future?
=================
The rest of the code would call this routine and check for the response (true being good and false being an error)
Hope this helps!
RoboGeek
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
BS2: $49
SX48 Protoboard: $10
Propeller Protoboard: Priceless
www.apple.com
www.parallax.com
www.goldmine-elec.com
www.expresspcb.com
www.jameco.com