Starting and stopping FDS Extended
Hugh
Posts: 362
The code I have written is using all cogs but I could really, really, do with another serial interface.
I may be being naive but what I hoped I would be able to do with a single FullDuplexSerialExtended object was along the lines of:
i.e., service two outputs alternately with only a single cog.
It doesn't seem to work (the second .start returns a value of -1).
I have tried storing the cogID returned when FDS is first started and then using cognew to start FDSE again in the same cog; I have tried including a delay between the steps.
So,
Hugh
I may be being naive but what I hoped I would be able to do with a single FullDuplexSerialExtended object was along the lines of:
Repeat Start the FDSE object (Pin 'A', 9600 baud). Tx stuff Stop the FDSE object Start the FDSE object (Pin 'B', 115200 baud). Tx stuff Stop the FDSE object
i.e., service two outputs alternately with only a single cog.
It doesn't seem to work (the second .start returns a value of -1).
I have tried storing the cogID returned when FDS is first started and then using cognew to start FDSE again in the same cog; I have tried including a delay between the steps.
So,
- Should this be possible?
- Am I missing a step between starting and stopping?
Hugh
Comments
+1
Here's a link to the OBEX. The development of this object was discussed in this thread.
If you're running low on RAM, I have a two port version which is smaller than the four port version. The two port version is part of the archive attached to this post.
My recalcitrance with regard to fullDuplexSerial4port was a degree of uncertainty on my part as to whether the four ports could be used across several cogs (I have individual cogs spending their time reading serial data and making it available to the main code).
I will try it when I get back home this evening.
Cheers
Hugh
The 4port object is usually initialized and started from the top level object. Then, other objects can declare it in their OBJ block and use it, other cogs if necessary. All the objects have access to those same 4 serial ports.
If multiple cogs try to access one of the ports at the same time, reading or writing, that would mingle the data streams, probably not a good thing.
In the top object file I have declared "ser" as the FDS4P object and added ports as below, with the intention that other PUBs running in dedicated cogs could use them:
(This code is in PUB Main)
At this point the other PUBs/cogs have not been started.
As written the code in 'Main' continues as expected. However, uncommenting the "ser.start" (Line 286 in "FFGPS115fsds4 - New board, tacho.spin", attached) causes 'Main' to stop 60 or so lines later (Line 347) . I don't think memory is being trampled over but it has got me scratching my head!
When in a spin file that contains only the code shown above data is sent perfectly (i.e., "Digital tacho2.spin")
I think I am stumped.
FFGPS115fsds4 - New board, tacho - Archive [Date 2014.05.22 Time 18.57].zip
Digital tacho2 - Archive [Date 2014.05.22 Time 18.59].zip
Thanks
Hugh
Note that you can change the CONstants for the buffer sizes. The Start method takes care of fitting them in. For example, you might want one buffer to be much larger in order to receive and send asynchronous packets, lets's say 1024 bytes and 120 bytes. And you might not need all 4 ports, so you can set SIZE constants to a small number. Make their SIZE = 4 (don't make it zero, dicey results)