My apologies, I fell asleep after eating something last night. As per our discussion last night, that error check was eliminated due to the handshaking revision. To avoid possible ENQ collisions, I altered the InterComm object and the demo to help prevent this from occuring. Please note the changes below to the InterComm object:
'Used by the parent object to determine if'an enquiry(ENQ) has been received, to help'avoid ENQ collisionsLONG EnquiryReceived 'TRUE or FALSE
PUBMasterTransmitSlaveReceive(LongValue1, LongValue2)
Serial.Str(STRING("The Master Is Now Sending Two Long Values To The Slave!"))
Serial.Tx(CR)
REPEATWHILE Master.IsHandshakeInitiated == TRUE
MasterTransmitTwoLongsToSlave(LongValue1, LongValue2)
PUBSlaveTransmitMasterReceive(LongValue1, LongValue2)
Serial.Str(STRING("The Slave Is Now Sending Two Long Values To The Master!"))
Serial.Tx(CR)
REPEATWHILE Slave.IsHandshakeInitiated == TRUE
SlaveTransmitTwoLongsToMaster(LongValue1, LongValue2)
Since my last post and update, I further updated the InterComm object as per MagIO2's recommendations as follows:
Hi Bruce,
some comments from my side:
1. You could move parsing after checking the CRC. Then you don't do the work in case the transmission was faulty.
2. Before putting it into the Obex, you should decrease the stacksize to the minimum. Some projects need to squeeze out any byte.
3. I see a problem with the if condition in the trim function. You should add OR CHAR==0. Then the trim will return latest when it found the string-end. With the CRC check before parsing it shoud not happen often that you parse a "rubbish" message, but even with CRC it can happen, as with a bad connection also the CRC could be corrupted and by coincindents match with the corrupt message.
Comments
My apologies, I fell asleep after eating something last night. As per our discussion last night, that error check was eliminated due to the handshaking revision. To avoid possible ENQ collisions, I altered the InterComm object and the demo to help prevent this from occuring. Please note the changes below to the InterComm object:
'Used by the parent object to determine if 'an enquiry(ENQ) has been received, to help 'avoid ENQ collisions LONG EnquiryReceived 'TRUE or FALSE
PUB IsHandshakeInitiated RETURN (EnquiryReceived <> 0)
PRI ProvideInterComm REPEAT IF InterCommMode == RX WaitForStatusEnquiry ReceiveDataWithCRC EnquiryReceived := FALSE IF InterCommMode == TX
PRI WaitForStatusEnquiry REPEAT WHILE InterCommMode <> TX IF Serial.Rxtime(500) == ENQ EnquiryReceived := TRUE Serial.Tx(RECEIVER_IS_READY) QUIT
And the following changes were made in the demo:
PUB MasterTransmitSlaveReceive(LongValue1, LongValue2) Serial.Str(STRING("The Master Is Now Sending Two Long Values To The Slave!")) Serial.Tx(CR) REPEAT WHILE Master.IsHandshakeInitiated == TRUE MasterTransmitTwoLongsToSlave(LongValue1, LongValue2)
PUB SlaveTransmitMasterReceive(LongValue1, LongValue2) Serial.Str(STRING("The Slave Is Now Sending Two Long Values To The Master!")) Serial.Tx(CR) REPEAT WHILE Slave.IsHandshakeInitiated == TRUE SlaveTransmitTwoLongsToMaster(LongValue1, LongValue2)
The attached demo includes these changes.
Bruce
Since my last post and update, I further updated the InterComm object as per MagIO2's recommendations as follows:
Please see the new attachment below
Bruce