Looking for suggestions pertaining to new object
idbruce
Posts: 6,197
Hello Everyone
In the attachment below, you will find an object that I have been working on. Most of the code has been tested, but some of it has not been tested. I am not asserting that it is error free, because I have no way to test it. I am just looking for simple suggestions to make it better, and perhaps a good set of eyes to look it over and find obvious errors, before I try to implement it with my machinery.
EDITED: Let me state for the record, this was initially intended to be a learning exercise for me and to provide me with the framework necessary for InterProp communications for my current project. In my current project, I have no need for highly repititious transmissions. As was pointed out to me, although I was aware of the potential problem, if this object were used for highly repititious transmissions, there would be a race condition for getting the available data out and overwriting the available data. In it's current state, the parent object would have to get the data out before a new transmission is received. Even though this will work for me, I believe it would be a much better object for all people if a solution were provided.
As a possible solution, I was thinking along the lines of having an array of LONGs where incoming data could be stored and read in a FIFO type manner. And then during idle time, after all data had been processed, clear the values contained within the array working backwards.
Another possible solution would be some type of BUSY indicator being set until the data had been processed by the parent.
Or perhaps a combination of both of these suggestions.
I am definitely open to complete solutions pertaining to the forementioned matter.
Additionally, although this has not been changed in the attachment below, the following method has been changed as seen below.
Thanks
Bruce
In the attachment below, you will find an object that I have been working on. Most of the code has been tested, but some of it has not been tested. I am not asserting that it is error free, because I have no way to test it. I am just looking for simple suggestions to make it better, and perhaps a good set of eyes to look it over and find obvious errors, before I try to implement it with my machinery.
EDITED: Let me state for the record, this was initially intended to be a learning exercise for me and to provide me with the framework necessary for InterProp communications for my current project. In my current project, I have no need for highly repititious transmissions. As was pointed out to me, although I was aware of the potential problem, if this object were used for highly repititious transmissions, there would be a race condition for getting the available data out and overwriting the available data. In it's current state, the parent object would have to get the data out before a new transmission is received. Even though this will work for me, I believe it would be a much better object for all people if a solution were provided.
As a possible solution, I was thinking along the lines of having an array of LONGs where incoming data could be stored and read in a FIFO type manner. And then during idle time, after all data had been processed, clear the values contained within the array working backwards.
Another possible solution would be some type of BUSY indicator being set until the data had been processed by the parent.
Or perhaps a combination of both of these suggestions.
I am definitely open to complete solutions pertaining to the forementioned matter.
Additionally, although this has not been changed in the attachment below, the following method has been changed as seen below.
PUB GetDataFields(DataField1Pointer, DataField2Pointer) 'This method can only be called once by the 'parent object, and then DataField1 and DataField2 'are set to zero. 'LONGMOVE(DataField1Pointer, @DataField1, 1) 'LONGMOVE(DataField2Pointer, @DataField2, 1) LONG[DataField1Pointer] := DataField1 LONG[DataField2Pointer] := DataField2 SetDataFieldsToZero NewDataAvailable := FALSE
Thanks
Bruce
Comments
I created a Hybrid interface and one of the options for communications can reproduce your circuit (just by throwing a switch). You may also want to present code to run with 3 props. This would get your name and code into the multi-prop Hall of Fame.
Prop to Prop custom message creation with parsing is still somewhat in its infancy and there is no doubt that your significant contributions to the OBEX will be useful and appreciated.
When it is finished, yes the same code will go into each prop.
That's easy. Just add the same object to the third prop. Pick two different pins in the master for rx and tx going to the third prop. And finally in the master prop, declare another instance of the object with a different name going to the third prop. That will be my setup for my machinery.
Bruce
I don't know if anyone has tried this before, but this is what I am going to attempt to simulate multi-prop serial communication for testing the object that I am working on.
Lucky for me that I have a spare Propeller Proto Board for testing
On (1) Propeller Proto Board I intend wire in this fashion:
Slave - IO Pin 1 - RX - 2.2K Resistor - TX - IO Pin 3
IO Pin 31 - RX - Prop Plug TX
IO Pin 30 - TX - Prop Plug RX
Slave : "InterComm" (requires 2 cogs)
Terminal : "FullDuplexSerial" (requires 1 cog)
It should work, we me luck
Bruce
Thanks for the rescue I was heating up my soldering iron
I am going to attempt some minor code modifications. I am going to change both DataField1 and DataField2 into arrays, and add four counters, ReadDF1Counter, ReadDF2Counter, WriteDF1Counter, and WriteDF2Counter for indexing the arrays. I have not got it all figured out yet, but I will probably add handshaking to the application to determine if one side is busy.
Bruce
I did not even stop to think about the example, but now that you mention it, this whole object is based upon that example. LOL But I thought it was accomplished a little differently than what I suggested, but I now see that it is not. If you had not presented that example in the first place, the source code above would not exist. That was the code that really got me thinking.
In my documentation, 17, 18, 19, and 20, are listed as device control without any specifics. Any way it goes, unless I am willing to do in depth research into serial communication protocol, I will just have to wing it. LOL Pick a number, any number.
Bruce
I have also been looking at ENQ(5)
Here is what I found:
I was thinking of using that as an inquiry to a BUSY flag and then using 17 - 20 to indicate status. Additionally, SOH should rightly come before STX.
Bruce
Here is the demo. I don't know why the values are coming back zero. I had similar calls with a different setup working the other day.
EDITED: In the following source remove NewDataAvailable := TRUE, I was using that for test purposes.
Bruce
Here is a clean version with all my known mistakes removed and a better demonstration.
Bruce
Here is the latest revision. Handshaking is now implemented. It is better, faster, stronger, and more dependable.
Bruce
I made some modifications to the object and demo. I am currently testing it within a loop, and as it stands right now, over 10,000 transmissions and receptions have been completed without one single error. I am going to just let it run for quite a while, and I will let you know the results later today. I was thinking that this object is perfect for G-Code transmissions and receptions between Propellers.
As we previously discussed, every situation will be a little different. I can foresee quite a few CNC'ers wanting to modify the parser and data input/output, but ending up in trouble. I think we could possibly make some spare change by making these modifications for them. And we could use the demo to let them know this service is available. I don't mind helping out here and there for free, but writing custom parsers and creating custom data input/output would be a little more time consuming. Would you be interested in something like that?
Bruce
Over 52,000 transmissions and receptions and still going strong.
And that is another fantastic idea!!!!!
Of course I am just guessing, but I would imagine, that there will we approximately 12 cnc mods per year.
The demo is not completely finished, but let me touch up one other thing, and I will upload it.
Bruce
Here is the latest copy with revisions to both the object and the demo. I will probably go over the demo one more time, to perhaps add one or two more strings. I am not sure yet.
You may want to alter the compact demo.
When I finally stopped it, over 56,000 TX/RX.
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.
I have not looked recently, but I am sure you know what you are saying by:
I was having a problem and I thought stack size might resolve it. Yes I will lower that.
I will definitely look at the following:
Thanks for the tips Andreas
Bruce
Are you still with me?
I definitely need your expertise with this one. I am trying to eliminate the 4 cog requirement for communication, therefore I would like to combine FDS with the InterComm object. I thought this was going to be a simple cut and paste, but I see it goes a little deeper. The attachment appears to be close, but in the "Start" method of FDS, the cognew goes into the "entry" method which is written in assembly. Is there a way to combine our "initialize" method into the "entry" method. Please take a peek.
Bruce
I just noticed several errors. Of course these will have to be remedied. But they are apparent.
Bruce
Yes, that is what I would like to accomplish one each, instead of two. I think it would be a much more attractive object if it only used one cog per comm. Picture a master that must communicate with two chips, that would be four cogs out the window.
Bruce
As much as I would like to participate in this, instead of throwing it on your shoulders, I just don't understand the assembly.
Bruce
This file should be in better shape. All readily apparent errors have been fixed.
Bruce
Think away my friend. I know you are a thinker.
Bruce
LOL Hmmmmm..... I can't answer that one!
Bruce
I removed the following methods from FDS because they weren't necessary for the InterComm, but perhaps they are necessary for compiling with the assembly code.
- PUB str
- PUB dec
- PUB hex
- PUB bin
Bruce