Multiple instances of Full Duplex Serial interacting
sstandfast
Posts: 39
I have an application that I am working on that the top level object uses the Full Duplex Serial object for debug/status purposes. The application also has a child object that uses its own instance of the Full Duplex Serial object. My prototype is built on the USB protoboard. Since the application will primarily run with the USB disconnected, I have set up the top object to first detect the state of the RX line of the FTDI chip at power up. This is used to determine if the unit is connected to the USB. If it detects a USB connection, then the top object starts/initializes its instance of the Full Duplex Serial object and then spits out debug/status data to the PC at certain key events. If the Prop does not detect the USB at power up, it waits up to 10 seconds before it skips the FDS initialization and sets a flag indicating that the USB is not present so the top object should skip all writes to that instance of the FDS object.
The child object's instance of Full Duplex Serial is always initialized and is independent of the top object's instance. The issue I am having is that when the USB is not connected, for some reason BOTH instances of FDS stop working. The rest of the application functions fine but all serial communication fails. As long as the USB is connected, all works fine. Has anyone seen something like this before? Just to be clear the setup is similar to this:
Then the child object looks similar to:
This is definitely not correct code, it is just merely intended to illustrate how the two objects are setup and why it is weird that by not initializing the top objects instance of FDS, the child's object ceases to function as well. Has anyone seen this before? If necessary I can post the actual code tomorrow, I just don't have access to it on this computer. Just let me know if you would like to look at it.
Shawn
The child object's instance of Full Duplex Serial is always initialized and is independent of the top object's instance. The issue I am having is that when the USB is not connected, for some reason BOTH instances of FDS stop working. The rest of the application functions fine but all serial communication fails. As long as the USB is connected, all works fine. Has anyone seen something like this before? Just to be clear the setup is similar to this:
'file top.spin obj mychild : "child.spin" debug : "FullDuplexSerial.spin" var USB_Detect pub main if ina[rx_pin] == 0 'no USB detected USB_Detect := false else 'USB detected debug.start(TX,RX,MODE,BAUD) USB_Detect := true myChild.start(TX_Node, RX_Node) if USB_Detect == true debug.str(string("Some Debug Data ") result := myChild.getStatus
Then the child object looks similar to:
'file child.spin obj serial : "FullDuplexSerial" pub start(tx_pin, rx_pin) serial.start( tx_pin, rx_pin, 0, 9600) 'Some more initializations. pub GetStatus serial.tx(......Status Request Message) Status := serial.rx return Status
This is definitely not correct code, it is just merely intended to illustrate how the two objects are setup and why it is weird that by not initializing the top objects instance of FDS, the child's object ceases to function as well. Has anyone seen this before? If necessary I can post the actual code tomorrow, I just don't have access to it on this computer. Just let me know if you would like to look at it.
Shawn
Comments
Thanks,
Shawn
Project.zip
I too found those few places this morning after posting, although some of those blocks are new additions that post-date the interaction issue. Namely the IF addr <> tmp block was added well after the USB problem was observed. The missing check in PrintNetworkConfig however, has been there from the beginning and is most likely where the problem is occurring, stalling the main loop and never initializing the remote nodes. I will retry the code when I get home from work.
I wish I could simply always initialize the top-level serial port but since this project is built on the Parallax USB Protoboard that is unfortunately not an option if this is to run with the USB disconnected. Otherwise I get constant resets caused by the FTDI chip.
Thanks for the heads up, I will post back with the results.
Shawn
@Dave - Using an unassigned pin is also an option, just not for this project since when it is all done, there will not be any unassigned pins. In fact, I am going to have to add a small PIC to the board with a serial interface to the Prop just to control a small HD44780 LCD because I don't have enought I/O on the Prop. There should be plenty of CPU power available, just not enough I/O, unless I get really creative with some multiplexing schemes.
I'll post back once I've had a chance to try out the new code changes.
Thanks for the feedback,
Shawn
Shawn