ForPortSerialPlus issues
RS_Jim
Posts: 1,766
Hi,
I have a bit of software that runs a wifi-module using full duplex serial 2 k., but when I try to use fourport serial plus, I get nothing on the wifi. I have configured the debug port to run in pst and it works but on the same initialization it does not run on the wifi.
Thanks for any help
Jim
wifi_webserver_090514 - Archive [Date 2014.09.26 Time 10.22].zipwifi_webserver_092214 - Archive [Date 2014.09.26 Time 10.21].zip
I have a bit of software that runs a wifi-module using full duplex serial 2 k., but when I try to use fourport serial plus, I get nothing on the wifi. I have configured the debug port to run in pst and it works but on the same initialization it does not run on the wifi.
Thanks for any help
Jim
wifi_webserver_090514 - Archive [Date 2014.09.26 Time 10.22].zipwifi_webserver_092214 - Archive [Date 2014.09.26 Time 10.21].zip
Comments
I don't see offhand where you have used the dio input methods in your code, but it seems to me they must be in there somewhere. And would cause the problem you described. Try that fix and let me know how it turns out.
I don't use that routine but will correct it. I lost input in the webchk method which just uses the rxcheck routine.
I wonder what happens if I move web to port 3?
Jim
I see you've increased the size of the port 1 buffer up to 2048 bytes for rx and 1024 for tx. That is fine , but it may be overkill, given that the target stringbuffer is only 64 bytes. Do you expect the web data to arrive in head-to-tail bursts? If so, the rxflush method calls would be flushing useful data.
I agree Tracy. I'd get rid of the repeated rxflush calls. I think these calls are probably throwing away a lot of your data.
I also agree about the stack size. I try to leave the main loop of my program running in cog#0 since (IIRC) the stack for this initial cog is all the unused memory in the hub.
I don't see a need for using "cognew" to start your "webthread" method. I think you'd be better off changing the end of your main method from:
To:
If you do need another cog to run some Spin code and this additional Spin code is more complex than the what "webthread" does, then launch "webthread" in the new cog but if your additional Spin code is less complex than "webthread" then launch this less complex code in a new cog. IMO, it's a good idea to keep the most complex Spin code running in cog #0.
I see you have "DataIO4port" listed in your objects. You don't call any methods in this object so it doesn't interfere with the program but if you were to call the start method of "DataIO4port" while still using "FullDuplexSerial4port", you'll likely encounter problems. I'm pretty sure you're only supposed to use "DataIO4port" or "FullDuplexSerial4port", not both.
Edit: It looks like I didn't understand how "DataIO4port" works. It doesn't launch a new PASM cog as I had incorrectly assumed. It looks like you are using it correctly (as far as I can tell).
I started web thread in a seperate cog because I am planning on running several objects in the prop at the same time an RTC, Barometer, web interface, wind direction and velocity, raingage, etc. I felt that running the web thread in its own cog was a good idea. I built the obj around fullduplexserial2K as you can see in my one zip file. That works just fine. The only issue I have with that version is I need to figure out how to write the html code to put the clock on its own line and update it without writing the whole page.
Increasing the stack space for webthread is something that I had not thought about. There is a line in my webcheck method that I use to test for incoming chars (may be commented out) that sends every byte that comes in to the text screen. what comes in after the command line that I parse out and use is all about the source device and the browser etc. I flush the data following the command line because it is unnecessary and I don't wish to be bothered by it. When I set it up to run on fourportserialplus, I lost all incomming data at webcheck method. Now a stack issue is something I never thought about and I certainly can increase the stack and recheck. I also can try running webthread in cog 0.I Don't know if I will be able to get back to this until Thursday, but will try. Some of the objects will probably get moved to another prop and there will be an xbee providing the coms between this unit running the web interface and the outdoor unit which will be running the data sensors. I forsee in the future needing to communicate with PST, the web port an an xbee,, thus the desireability of fourportserialplus. After I repair the bug error i DatIO4, I may use it instead of my webcheck method. I also want to change my RTC code to Toms code that he wrote for the SPI connection to the DS3234 changing it to I2C. I like his user interface and I am getting a lot of read errors from the clock chip using Kye's code for the other clock ship. Ineed to combine the clock and barometer functions onto a single I2C bus and free up some pins. I will try out the PASM version of the driver and see if I can make it work.
Thanks for looking into the code, I will try some things and report back when I have further information.
Jim
I usually start with large stacks and reduce them once things are working correctly. I once thought I have way over estimated the stack space at 100 longs only to find the cog was actually using more.
I use a program similar to the one attached to post #13 of this thread to check stack size. (Make sure and fill stack with test pattern before launching cog.)
I like to leave the stack checking method running for a while as I use the code. IMO, it's kind of fun to see the size of the stack change as different branches of a program are executed.
I edited the program and changed stack to 256, and max str length to pick up the port. Still get absolutely nothing! Need to move on and get some other things done. Will revisit 4port obj again at a later date.
Jim
I you have a version I could run on my hardware, I'd be willing to try it out. I use the four port serial object everyday and I don't often have a problem with it (I never really have a problem with it, the problem is always something I did wrong).
I have both objects in the first post. I think that all the pins etc. are shown as constants. I currently have it running on a demo board.the archive in the first post doesn't reflect the increased stack size.
I would love to have you test it. The wifi module is one of the serial ones I bought from OBC. Should work with one of the new $5 wifi boards.
You should be able to comment out the rtc code and objects as they don't add anything to the serial problem.
Jim
Good thought. However, in this case all I did was exchange 4port serial for full duplex serial. They both use the same call, "rxcheck"
This is where the system fails. I can set up a debug port and send and receive to PST from it, but the web port gets nothing using 4portserialplus.
Jim
The earlier program using FullDuplexSerial_2k_051414 declares the port as follows,
whereas the new one does it with the TX and RX switched. Is that intentional?
Boy did that stir up a can of worms! I went back and edited the 4port version and I started getting the receive side to work and it would print out what was comming into web RXCheck. The string parseing was working correctly and the string matching works as the printer power and main power leds go on and off as commanded. BUT, there is no serial output to the web device! What is interesting, I went back and checked the origional usage for that serial connection and all of the definations have rx and tx in reverse order. Now I wonder if the full duplex serial 4 k is somehow corrupted and the start order for rx and tx are somehow reversed? I am using a little program I call VGAWifitester to communicate with the wifi module when I need to use the command mode on it and alter its setting. I use the command mode to find out which port it is on as I have had some recent problems with the wifi needing to reboot and the DHCP keeps moving ports around.
The source for the fullduplexserial4K should be part of the archive, maybe you can see a clue there.
Thanks for looking at the code.
Jim
)
In your program though, transmit and receive are defined from the perspective of the web device, W_TX_PIN to transmit from the device to the propeller, so you end up with the W_TX_PIN constant in the rxpin spot in the fds2k, and W_RX_PIN is in the txpin spot. But it got reversed when moving to the 4-port object.
It seems to me reversing both of them should have fixed it, rather than opening the can of worms(!?). The archive I'm looking at is dated 090514 and uses FullDuplexSerial_2k_051414.spin. Is that the one you mean that had been working before?
Yes that one works. I guess I need to repair the test lead on my USB scope and measure incoming and outgoing signals.
Jim
fds.Str(webport,@Page_header)
should work with either serial port object. The Str methods are virtually identical. The Prop tx pin could be locked high if some other cog (other than the serial psam) sets it high, but that would be true of either version.
Jim
Jim
Just rechecked data sheet, clearly says no pullup/down on uart ports. I will go check to see if there is any difference between 4portserialplus and fullduplexserial in the state of the transmit pin at eot.
Jim
In the code that I've seen, the UARTS have been set for driven operation, not open mode. The tx pin is asserted both high and low by the Propeller. So there shouldn't be need for pullups/downs. An oscilloscope can help, because you can verify that output levels are in fact what they are supposed to be and are the same between the one that works and the one that doesn't, and if there is any funny business like noise or spikes. A logic analyzer will show you the stream of data by ascii code, and the timing between characters.
I finally got a chance to take advantage of an unused port in the fourport obj, and I used Parallax Serial Terminal to look at what the Prop was sending out to the wifi port. It was sending exactly what it was told to send, ie the HTML code that was dependent upon how the string parsed. I finally found out why I was not seeing any response on the iPad when I used fourport serial plus. In the working version, I was sending out a CR,LF pair before I sent any of the HTML code. That was missing in the fourport version. I don't know why the wifi transceiver needs that before it will send any HTML code, but it does. So now that I have wrapped my head around the fact that when the periferial says TX and RX, The TXpin is the RXpin on the prop. and the RXPin is the TXPin on the Prop. Boy I hope I never make that mistake again!
Thanks to all for all of their help and suggestions.
Jim