Full Dup Serial question
T Chap
Posts: 4,223
If multiple methods/cog are using the ser.tx or ser.str, does the object manage what is received and send out in the order received?
The case would be two cogs want to ser.tx at the same time. I am trying to find a way to have several strings assembled together and send out, while maintaining each ones individual 0 termination so the receiver can split the parts. To have the receiver be able to identify what is coming in and write it to it's respective array or variable, this is the thought process although not execute yet until I see how the object will manage multiple sources of .tx or .str"
say Xcheck is a string(or already converted into an integer) that was just rec'd in the buffer among 3 other integers(Y,Z,R). I want to send those back where they cam from for error checking prior to any action. However, there may be a case where some activity is taking place where a cog(s) may be sending values independently of the error checking Tx getting sent. If in fact the Full Dup object can manage multiple sources of instructions, and tere will be cases where things are competing to get sent, I don't see a tidy way to simply send the error checking string out as it was received without first giving each part a unique identifier first, so that the receiver must first identify something in the batch of stuff, split it's part out and assign it back to some arrays as needed.... compare, and then resend a confimation. In other words this is a brain twister.
Here is a feeble attempt:
1. receive a string with 4 integers included
2. split the numbers out to X, Y, Z, R
3. Assemble a new string by some method:
TAB = $09
CR = $0D
ser.str("Xcheck" + TAB + X + TAB + "Ycheck" + TAB + Y + TAB + "Zcheck" + TAB + Z + TAB + "Rcheck" + TAB + R + CR)
4. The receiver looks for Xcheck, if true stores that whole string in an array ErrorCheck()
5. Split and compare the parts
On the right path or what?
Thanks
The case would be two cogs want to ser.tx at the same time. I am trying to find a way to have several strings assembled together and send out, while maintaining each ones individual 0 termination so the receiver can split the parts. To have the receiver be able to identify what is coming in and write it to it's respective array or variable, this is the thought process although not execute yet until I see how the object will manage multiple sources of .tx or .str"
say Xcheck is a string(or already converted into an integer) that was just rec'd in the buffer among 3 other integers(Y,Z,R). I want to send those back where they cam from for error checking prior to any action. However, there may be a case where some activity is taking place where a cog(s) may be sending values independently of the error checking Tx getting sent. If in fact the Full Dup object can manage multiple sources of instructions, and tere will be cases where things are competing to get sent, I don't see a tidy way to simply send the error checking string out as it was received without first giving each part a unique identifier first, so that the receiver must first identify something in the batch of stuff, split it's part out and assign it back to some arrays as needed.... compare, and then resend a confimation. In other words this is a brain twister.
Here is a feeble attempt:
1. receive a string with 4 integers included
2. split the numbers out to X, Y, Z, R
3. Assemble a new string by some method:
TAB = $09
CR = $0D
ser.str("Xcheck" + TAB + X + TAB + "Ycheck" + TAB + Y + TAB + "Zcheck" + TAB + Z + TAB + "Rcheck" + TAB + R + CR)
4. The receiver looks for Xcheck, if true stores that whole string in an array ErrorCheck()
5. Split and compare the parts
On the right path or what?
Thanks
Comments
Mike
This may not be kosher but here is my workaround I was about to test.
Post Edited (originator99) : 11/4/2006 7:45:59 AM GMT
Between the time you check S the last time in "while S == 1" and the time you set it to 1, someone else may have already set it. In this case, both cogs would think they had set it to 1, and had taken unique ownership of it.
This will cause weird, difficult-to-track errors. (You think it's weird here, try it with a million processes.)
As Mike pointed out, use the lock operations in SPIN. You can use them exactly the same way you're using S -- there's an example in the manual that shows how. It's not complex, and it's the easiest way to do this sort of "in use" flag on the Propeller.
So far it has solved the problem and my test feedback window that displays all incoming data to the app is now showing everything in order, not mangled parts thrown together like in a blender as before.
repeat until not lockset(SemID)
'read or write some shared junk
lockclr(SemID)
can be split as folows:
Not completely unfounded, actually -- taken literally, that statement is correct.
They have to get their turn at the variables to read or write -- but not both! A cog can read the variable and decide "Oh, great, it's clear! I will set it." Then it must wait its turn to set it -- and in the meantime, another Cog may have reached the same conclusion. *sad music plays*
You nailed it. Good work!