Our full technical support staff does not monitor this forum. If you need assistance from a member of our staff, please submit your question from the Ask a Question page.


Log in or register to post/reply in the forum.

FTPclient working just once after CR6 reboot (TCP connection doesnt restart after PPPclose instruction)


Yoann MICHIELIN Sep 2, 2016 10:35 AM

Hi,

I use the code below to switch on my Wavecom modem, send the available data with FTPclient instruction and then switch off the modem. My problem is that the FTP transfer is completed only the first scan after a datalogger reboot (sending a new program, manual reboot...) and after it doesnt work no more. I used the FTP trace function to get more information about what happens, and after the second scan i get "tcp_open timed out" message.

  • My datalogger is a Campbell CR6 with the latest firmware update
  • I tried in passive FTP mode (option 8) and in active FTP mode (option 9) and it doesnt change anything
  • The IP adress resulting of the PPPopen instruction is always ok, even when I get "tcp_open timed out" message in the FTP trace comport. The PPP network Status :            ppp state: dialed -> IP Opened
               IP: 90.121.231.171
  • I dont have this problem when I dont close and open the PPP connexion between two calls of the FTPclient instruction

Have you got some ideas of where does the problem come from ?

Thanks a lot for your help,

Yoann MICHIELIN

CRBASIC CODE :

Const PORT_MODEM = ComME
Const BAUDRATE_MODEM = 115200
Const SW12_MODEM = 1
Const HOST_FTP = "ftp.lthe.fr"
Const USERNAME_FTP = xxxxxx
Const PASSWORD_FTP = xxxxxx
Const FILE_REMOTE = "data.dat"

Const CR=CHR(13)
Const LF=CHR(10)
Const CRLF=CR+LF


Public PTemp As Float
Public batt_volt As Float
Public resultFTP As Long
Public ip as String

Units batt_volt=Volts
Units PTemp=Deg C



DataTable (table,1,9999)
  Minimum (1,batt_volt,FP2,0,False)
  Sample (1,PTemp,FP2)
EndTable



Sub ModemOFF
  PPPClose
  SerialOpen(PORT_MODEM,BAUDRATE_MODEM,0,20000,100)
  SerialOut(PORT_MODEM,"AT+CFUN=0" + CRLF,"OK",2,200)
  Delay(1,5,sec)
  SerialClose(PORT_MODEM)
  SW12(SW12_MODEM,0)
  Delay(1,5,sec)
EndSub


Sub ModemON
  SW12(SW12_MODEM,1)
  Delay(1,45,sec)
  ip = PPPOpen
  Delay(1,15,sec)
EndSub



BeginProg
  Scan (20,sec,0,0)
    PanelTemp (PTemp,250)
    Battery (batt_volt)
    CallTable table
  NextScan

  SlowSequence
  Scan(2,min,0,0)
    modemON()   
    resultFTP = FTPClient (HOST_FTP,USERNAME_FTP,PASSWORD_FTP,"table",FILE_REMOTE,9,0,0,Min,-1008,1000)  
    modemOFF()  
  NextScan
EndProg

FTP TRACE :

 opening 9

 hit ESC to exit, any other key to renew timeout

11:53:02.111 T 11:53:01.963  ftp rx: 220 Bienvenue sur le serveur FTP du LTHE.
11:53:02.111 T 11:53:01.963  USER riple-ftp
11:53:02.111 T 11:53:01.963  
11:53:02.611 T 11:53:02.492  ftp rx: 331 Please specify the password.
11:53:02.611 T 11:53:02.492  PASS !Riple2016!
11:53:02.611 T 11:53:02.492  
11:53:03.111 T 11:53:03.064  ftp rx: 230 Login successful.
11:53:03.111 T 11:53:03.064  TYPE I
11:53:03.611 T 11:53:03.590  ftp rx: 200 Switching to Binary mode.
11:53:03.611 T 11:53:03.590  PASV
11:53:04.361 T 11:53:04.146  ftp rx: 227 Entering Passive Mode (152,77,121,7,46,124).
11:53:04.361 T 11:53:04.147  NLST data.dat
11:53:04.361 T 11:53:04.147  
11:53:05.361 T 11:53:05.225  ftp rx: 150 Here comes the directory listing.
11:53:05.861 T 11:53:05.741  ftp rx: 226 Directory send OK.
11:53:05.861 T 11:53:05.741  Closing handle 102.  Connection aborted.
11:53:05.861 T 11:53:05.741  PASV
11:53:06.361 T 11:53:06.306  ftp rx: 227 Entering Passive Mode (152,77,121,7,109,151).
11:53:06.361 T 11:53:06.306  APPE data.dat
11:53:06.361 T 11:53:06.306  
11:53:07.611 T 11:53:07.384  ftp rx: 150 Ok to send data.
11:53:08.861 T 11:53:08.764  ftp rx: 226 Transfer complete.
11:53:08.861 T 11:53:08.764  QUIT
11:53:09.361 T 11:53:09.288  ftp rx: 221 Goodbye.
11:53:09.361 T 11:53:09.288  ftp client SUCCESS
11:55:17.611 T 11:55:17.474  tcp_open timed out
11:55:17.611 T 11:55:17.474  failed to connect with ftp.lthe.fr on port 21, Connection aborted.
11:55:17.611 T
11:55:17.611 T 11:55:17.474  ftp client FAILED
11:57:17.861 T 11:57:17.616  tcp_open timed out
11:57:17.861 T 11:57:17.616  failed to connect with ftp.lthe.fr on port 21, Connection aborted.
11:57:17.861 T
11:57:17.861 T 11:57:17.616  ftp client FAILED
11:58:27.361 T 11:58:27.111  Closing handle 101.  Connection aborted.
11:59:17.361 T 11:59:17.356  tcp_open timed out
11:59:17.361 T 11:59:17.356  failed to connect with ftp.lthe.fr on port 21, Connection aborted.
11:59:17.361 T
11:59:17.361 T 11:59:17.356  ftp client FAILED


GaryTRoberts Sep 8, 2016 02:50 AM

Is the datalogger getting an IP address every time?  What does ip = when the FTPClient() instruction is failing?


emb66 Sep 8, 2016 01:10 PM

Serialopen at modem on?

Why at+cfun at every close?


Yoann MICHIELIN Sep 9, 2016 03:02 PM

GaryTRoberts :

Yes the datalogger gets an IP adress everytime after the PPPopen instruction (for example, ip = 90.121.231.171, I never get an IP of 0.0.0.0) but the TCP connection fails, and so the FTPclient instruction fails too.

emb66 : 

I use serialOpen just to talk to the modem with AT commands. I cant use a PPP connection through the modem and talk with it with AT commands at the same time. That's why I have to close the PPP connection before opening a serial communcation with the modem.

at+cfun is used to switch off the modem properly.

Thank you for your responses.

Yoann


Yoann MICHIELIN Sep 27, 2016 03:39 PM

[PROBLEM SOLVED]

I was using the ethernet port to log images from an IP camera, and my modem was connected on the ComME Port through the SC932 module. There was a conflict between Ethernet and the PPP (modem) when they are both opened and when I use the FTPclient instruction. 

To solve this I use the EthernetPower() instruction to open the ethernet port only when I want my camera to send an image on the CR6, and then I shutdown the ethernet before calling the FTPclient instruction.

I don't have skills in networks, so maybe this is absolutely logic (if so, can you give me explanations please), but maybe it will help others who have the same issue...

Yoann


JDavis Sep 27, 2016 03:49 PM

It is possible you may have been able to solve this with the IPRoute instruction. IPRoute let's you force a connection, like to the FTP server, to use a particular interface.

Log in or register to post/reply in the forum.