LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to create a fixed IP TCP Server

Hello, I´m new working with TCP protocol, I´m using an ESP8266 as a client (controlled by a PIC18F2550), and a TCP Listen to wait for the connection, but I have to know the PC's IP and program the PIC with that IP, etc. It works, but when I want to use it with another PC, the IP changes, and I have to reprogram the PIC with the new IP.

Is there a way to assign a new IP from LabVIEW? Or create a server with a desired IP?

Thanks.

Hello from Mexico.

0 Kudos
Message 1 of 8
(3,838 Views)

Hi,

 

       Make your PIC IP Static. If its running Linux write some shell script to make it Static. 

  

Message 2 of 8
(3,829 Views)

TCP/IP doesn't quite work the way you would like it. The IP address that a TCP/IP server uses is not assigned by the server. It simply starts up and waits for whatever connection requests arrive, and those connection requests only can arrive if they are directed to to the IP address that the computer on which the server is running, has been assigned to when it was installed/configured.

 

So if you change your server computer, the IP address to which your client connects also changes. That is why there was DNS invented which maintains a decentralized registry of domain names versus IP addresses so that a client can connect to a well known domain name adres rather than a cryptic IP number that may change whenever the server computer is replaced. However implementing a proper DNS solution is a lot of work, and needs regular maintenance.

 

A pragmatic but quick solution would be probably to have the IP adres stored in some file or memory adres location on your PIC, that can be easily modified through your terminal connection or whatever, so that you do not always have to recompile your PIC program when you need to change the server computer. On startup of your client you read that file or memory adres and use the adres to connect to your server.

Rolf Kalbermatter  My Blog
DEMO, Electronic and Mechanical Support department, room 36.LB00.390
Message 3 of 8
(3,809 Views)

Thanks for the info

So I have to store the IP of the server in the PIC.

0 Kudos
Message 4 of 8
(3,728 Views)

Or turn it around and make the PIC the server. You should probably know from your PC app with which PIC you want to talk and what IP address it has.

Rolf Kalbermatter  My Blog
DEMO, Electronic and Mechanical Support department, room 36.LB00.390
0 Kudos
Message 5 of 8
(3,721 Views)

Well in fact that was my first option, but the module ESP8266 has a "transparent transmission" mode that fits better to my needs, and this mode need the module config as a client, so the option of store the IP of "LabVIEW"in the PIC is good.

I have another problem.

Do you know whats is the max loop frequency for each transmission?

I mean, the timed loop of the VI fist Sends "x" bytes to the PIC (using TCP Write) and then receives "y" bytes from the PIC (using TCP Read).

The PIC sends the bytes 1ms later than it receives from LabVIEW. And the operation takes 2ms. But despite the timed loop is set to 10ms, each iteration takes 30ms.

Do you know why?.

Thanks.

 

 

0 Kudos
Message 6 of 8
(3,691 Views)

@Hector94 wrote:

 

The PIC sends the bytes 1ms later than it receives from LabVIEW. And the operation takes 2ms. But despite the timed loop is set to 10ms, each iteration takes 30ms.

Do you know why?.


We could start guessing, but some code will help.

0 Kudos
Message 7 of 8
(3,664 Views)

Hello

That's the code, this loop goes later than the ESP8266 connects to the server (LabVIEW).

With the oscilloscope I found that seach transmission takes less than 2ms and the.

So I don't know where is the delay.

Thanks

0 Kudos
Message 8 of 8
(3,648 Views)