Tibbo Lan to serial code needs a reboot to run after power up - Why?
Is there anything that I can code into the Tibbo to guarantee full operation on power up without the need to send a command from the PC?
The more people who report this problem, the more it gets noticed.
-
Inappropriate?Sounds like your code is still in Debug Mode.
Try this in Tibbo IDE:
1) Load your project
2) Go to Project > Settings
3) Uncheck "Debug version"
4) Click OK
5) Compile/upload
Then test it by turning the device off and back on. Your code should start automatically.
Tell me how it goes. -
Inappropriate?Tried that and just retried that. The exact sequence of events was....
0. Load the project
1. Add a dummy line of code to the code.
2. Check and uncheck ( just to be sure) the debug box
3. Upload (but do not restart through tibbo)
4. Remove all cables
5. Power down the tibbo
6. Reconnect all cables
6. Power up the tibbo
7. Try to connect.
No joy. Is there anything else I can try?
I’m confused
-
Inappropriate?When I say - no joy, the lights flash on the TIBBO as they should (a steady double pulse of the green light). But when Com 2 is opened (as witnessed by a serial port sniffer on the PC) the Tibbo does not switch to a continuous green light indicating port open.
Might it be that the virtual port code is not sending the correct wake up call to the Tibbo? Maybe there is a code revision issue at the PC end?
I’m anxious
-
Inappropriate?Hi David,
Sorry for not replying for so long - this got buried in my inbox.
Can you paste your code here? -
Inappropriate?Here you go - I am basically using your "net_to_ser_1.tpr" project with a ser.rxclear, and a sock.rxclear just before data is grabbed from buffers.
'***********************************************************************************************************
' THE SIMPLEST DEVICE SERVER (WITHOUT ACTIVE OPENS, WITHOUT BUFFER REDIRECTION)
'***********************************************************************************************************
'This project can run on EM202 and EM1000 platforms. Select platfomr in Project->Settings. If your
'platform is EM1000 then uncomment the code below marked as "EM1000 ONLY". After that do
'Project->Rebuild All.
'***********************************************************************************************************
' This project implements the simplest "serial device server" possible. There is a single TCP
'connection (passive opens only). Once this connection is established, whatever is received
'through TCP is sent out via the serial port and vice versa.
'
' ATTENTION! READ THE COMMENTS IN CODE! YOU MIGHT NEED TO CHANGE THE PROGRAM! For example,
'you may need to set correct IP address, baudrate, etc.
'=============================================================
sub on_sys_init
'This event is always generated first. We use it to setup everything- a socket for TCP
'connection, serial port, etc.
'ATTENTION! Read this code- you might need to do some parameter changes!
dim w as word
dim debug1 as word
'---------- EM1000 ONLY (uncomment if you are using EM1000) ----------
'io.num=PL_IO_NUM_0 'RTS line of serial port 0
'io.enabled=YES 'we configure this line as output
'---------------------------------------------------------------------
net.ip="192.168.1.95" '<<<<<<<<<< IP-address of this device. CHANGE AS NEEDED!
'Next, we request memory for the only socket we need. This is a simple allocation-
'we ASSUME that we have enough memory for what we request.
sock.num=0
sock.rxbuffrq(4) 'we ask for 4*256-16=1008 bytes for the RX buffer of socket 0
sock.txbuffrq(4) 'we ask for 4*256-16=1008 bytes for the TX buffer of socket 0
'Now, we request memory for the serial port. This is a simple allocation- we ASSUME
'that we have enough memory for what we request.
sock.num=0 'Good practice (but, actually, redundant)
ser.rxbuffrq(4) 'we ask for 4*256-16=1008 bytes for the RX buffer of the serial port
ser.txbuffrq(4) 'we ask for 4*256-16=1008 bytes for the TX buffer of the serial port
sys.buffalloc 'And now ACTUAL buffer memory allocation
'We need to setup our socket for TCP/IP.
sock.num=0 'Good practice (but, actually, redundant)
sock.protocol=PL_SOCK_PROTOCOL_TCP 'We set TCP
sock.localportlist="1001" '<<<<<<<<<< Listening ports. CHANGE AS NEEDED!
sock.inconmode = PL_SOCK_INCONMODE_ANY_IP_ANY_PORT 'Accept connection from any host
'Serial port also needs setup (we leave parity and bits/word at default- NO and 8)
ser.num=0 'Good practice (but, actually, redundant)
ser.flowcontrol=DISABLED '<<<<<<<<<< Flow control ON. CHANGE AS NEEDED!
ser.baudrate=ser.div9600 '/4 = We want to run at 38400bps
ser.bits = PL_SER_BB_7
ser.parity = PL_SER_PR_EVEN
ser.enabled=YES 'The serial port is now ON!
'It is nice when your device provides some visual status of what it is doing.
'After we boot, let's play a "power-on" pattern on the LEDs!
pat.play("B-B-B------",YES) 'Blink Red & Green 3 times. <<<<<<<<<< CHANGE IF YOU WISH!
end sub
'=============================================================
sub on_sock_data_arrival
'This event is generated whenever there is an incoming TCP data to process.
'All arriving TCP data is sent out through the serial port.
'You may feel that the code below is a bit cryptic but, actually, it is very simple!
'We use sock.getdata() to extract a portion of data from the socket's RX buffer. We plan
'to put this data into the TX buffer of the serial port. Therefore, we should be mindful
'of the free space in the TX buffer. We only extract as much data from the RX buffer
'of the socket as available free space in the TX buffer of the serial port. This is achieved
'through the use of the ser.txfree property. The ser.setdata() method stores the data into
'the TX buffer of the serial port.
ser.rxclear
ser.setdata(sock.getdata(ser.txfree))
ser.send
end sub
'=============================================================
sub on_ser_data_arrival
'This event is generated whenever there is an incoming serial data to process.
'All arriving TCP data is sent out through the TCP connection.
'The code below is like the code for the on_sock_data_arrival event (see above), only in
'reverse. It copies the data from the RX buffer of the serial port and into the TX buffer
'of the socket.
sock.rxclear
sock.setdata(ser.getdata(sock.txfree))
sock.send
end sub
'=============================================================
sub on_sock_event(newstate as pl_sock_state,newstatesimple as pl_sock_state_simple)
'This event is generated whenever socket status changes. We are only using a single socket (#0) so
'we can be sure that this event is related to it.
'Here is what we do: we don't check the socket state here, we just play a very short
'LED pattern which momentarily dims bot Red and Green LEDs. When this pattern is done playing
'the on_pat event will be generated and we will check socket state there!
pat.play("-",YES)
end sub
'=============================================================
sub on_pat
'This event is generated each time previously loaded LED pattern has finished playing. We load
'new pattern basing on the current state of socket0 connection.
sock.num=0 'Good practice but also redundant for our project
'We just recognize 2 states: connected/not connected
if sock.statesimple=PL_SSTS_EST then
pat.play("GGGGGGGGGGGGGGGG",NO) 'Connection established- Green LED steadily on
else
pat.play("-------------G-G",NO) 'Connection is not established- Green LED double-blinks
end if
end sub
sub on_sock_inband()
' TODO: place "on_sock_inband" event handler code here...
end sub
I’m undecided
-
Inappropriate?I just tried your code here David, and I can run it fine? What version of TIDE and TiOS firmware are you using? It shouldn't matter but might be something to look into. Do try the latest to see if the problem goes away.
-
Inappropriate?I found that the code does run fine when running in the TIBBO IDE, but has trouble stand alone. Did you drop out of the IDE, power down the unit, power back up again - say 10 seconds later, then try opening the port with whatever application requires the serial port?
I am running ...
TiOS code version ...2.05.01
TIDE ... 2.6.22 Beta Built on March 26th 2008, 18.11.16
I will be getting another unit in the next few days. I will run the same code in that and do another test on the bench. I get around the problem for now by sending the restart comand over the net whenever I lose comms, but I would like to get to the bottom of this one if I can.
Thanks in advance
I’m unconcerned
-
Inappropriate?yea, I did run it out of the TIDE, I even had the project closed (not that this should matter once you are not using the debug mode). I did even disconnect for a prolonged period of time before reconnecting the cables and power back on. Maybe it is something with that particular module?
-
Inappropriate?Perhaps, when I get my next unit I will be able to check that one out. I will post my results once I have worked through that.
I’m undecided
Loading Profile...




EMPLOYEE