Variable Question
172heavy
Posts: 55
I am working on a simple program and I have a NEWBIE question. If I call FullDuplexSerialPlus.spin from two seperate objects will the variables conflict since they are named the same? I have to call the fullduplexserialplus to in order to DEBUG the program so in the final application I will only need to call it once. Then I call it a second time from the GPS_IO_mini.spin which parses the NEMA strings. I dont seem to be getting any data from the NEMA strings so I was wondering if the two instances of fullduplexserialplus are conflicting. I know the gps is sending the data, I plugged it in directly to the serial port on my laptop and I can read the strings from the terminal program.
Also I know the Serial to USB adapter converts the data coming from the prop to the terminal to the USB format but does it do anything else to the data? It seems that I can send serial data out of say pin 1 to the terminal and it is incorrect, however if I send the exact same data through pin 30 throught USB then all is ok. Any help would be appreciated.
Josh
Also I know the Serial to USB adapter converts the data coming from the prop to the terminal to the USB format but does it do anything else to the data? It seems that I can send serial data out of say pin 1 to the terminal and it is incorrect, however if I send the exact same data through pin 30 throught USB then all is ok. Any help would be appreciated.
Josh
Comments
For example...
However, read what Mike says below.
You also get multiple copies of whatever objects are used. For example, you'd have two copies of FullDuplexSerialPlus each of which use a separate copy of FullDuplexSerial.
Note that only one copy of the code itself is used. Only the variables are duplicated.
You can get into trouble two ways
1) Each FullDuplexSerialPlus copy calls FullDuplexSerial to start up a cog to do the actual serial I/O. If these try to use the same I/O pins, there'll be a conflict
2) Some I/O drivers use variables in their DAT section deliberately so they can have multiple copies that work together. If you have something like FullDuplexSerialPlus that calls another object, these may have to work together depending on how they're written.
Generally to get help, you need to post a copy of your program along with some detail about what you observe happening. Use the "paperclip" icon to attach your files to a message. Try to use the archive feature of the Propeller Tool to package up your source program along with objects you reference all in one ZIP file, then attach that.
never mind what I said. Listen to what Mike says. I forgot about pins conflicting with each other, for example.
I have included a copy of my project, please don't laugh I am a newbie so I know the code is probably not organized. I am just trying to feel my way through this. I would appreciate any tips if anyone has time.
Question, I have fullduplexserialplus called by one object and fullduplexserial_mini which is basically a slimmed down version of fullduplexserial called by another object so the Dat and the variables are the same, do you think this will cause conflict?
Verify baud rate, parity (it depends on your GPS), and as a last note try to swap the pins...
As a side note: for debug use the "parallax serila terminal" object.
Massimo
Thanks for the response, I will check the serial terminal object out.
What are you trying to do?
I am trying to bring the NEMA data in on PIN 14 and "debug" the result on pin 30, the only way the data makes any sense on the terminal program is if I debug through the propclip USB plug (pin30). I sent some known values out via pin 1 baud 4800, 9600 etc and the terminal program doesn't display the values correctly, I then sent the same string out through the propclip (pin30) and voila it worked, I need to figure this out as well but i fugured one thing at a time.
I figured the different instances of the similiar object would be overwriting my pin designations so I decided to use the same pins since I only needed one object to receive and the other to transmit I didnt figure it would be a big deal.........
I actually tried it a few times after I commented out the viewport stuff so I was just using pin 30 to xmit the results of the incoming strings but I had the same problem, it seems like the strings are not getting picked up for some reason so I figured that I was trying to write to a variable that was getting overwritten by another instance of the FULLDUPLEXSERIAL OR FULLDUPLEXSERIAL_MINI.\
I guess my main question would be how would someone go about using one cog to receive data and another cog to transmit data (Serial) Do I need to can I use the same object to perform both and just change the parameters to seperate pins?
1) You can use a full duplex I/O driver like FullDuplexSerial to transmit on one pin and receive on another pin. Once you start the object (call .start with the pin numbers, Baud, and mode), the transmit side and receive side work independently. Note that you can't refer to the FullDuplexSerial driver from two different objects. That gives you two different copies working in two separate cogs at the same time.
2) You can use something like the Simple Serial I/O driver and just specify only a transmit pin or a receive pin when you initialize it. You can have two copies, each handling only one I/O pin. The other pin # is specified as -1 as mentioned in the comments in the Simple Serial source. You can't do the -1 thing with most other I/O drivers ... it's a specific special case with Simple Serial. You can use two different copies of Simple Serial at the same time as long as they don't attempt to use the same I/O pins.
If you use ViewPort, you can't use another I/O driver on the same I/O pins (30 and 31). If you want to transmit to the PC using I/O pin 30, you have to remove or comment out the references to the ViewPort object.
I will keep that in mind, I appreciate all of your help. Thank you.