hi,
I have arduino Uno + ethernet shield, using that i have developed a code of web server and a code to query RS485 device. Pc is used as tcp client and arduino as server in both codes. Now i want to combine these two codes in one but don't know how to do this because once the webpage is loaded client is disconnected from the server so how do i reconnect it with arduino(server). I can not copy the codes because of its long length so I have attached both the codes.
You cannot have two servers with different protocols running on the same port. With the standard Arduino Ethernet library you even cannot have two servers running on different ports. Decide if you want to have the Arduino serving HTTP or that proprietary RS485 protocol. Both options look feasible to me but I don't know what implications that may have on your PC side. You then have to integrate the baud rate control into the proprietary protocol or send/receive RS485 date over HTTP using the web server.
If you tell us more about the software running on the PC we may help you further and give you hints on how to decide between the two options above.
the thing is i have only 1 server i.e. arduino and the RS485 query code will execute continuously to read/write slave device's parameters. Now the code portion for webserver i.e. to change baud rate n protocol configuration will not executed regular. If any one changes these parameters in the a.c. drive then i need to change it in my rs485 code in arduino through webserver code to keep reading drive parameters.
Right now i m using a Hercules Setup utility application as TCP client to query slave device. From pc (as client )ethernet connection to arduino server and on serial port arduino as master to slave a.c. drive through rs 485 converter.
Tell me if any other information required and pls guid me how to achieve this
With that code, you must reconnect. The client opens a connection and sends a request. The server sends a reply and closes the connection. If you want to send another request, you must connect again.