I am able to do ping, like a server and like a client. But I need some suggestions. Let me explain my project:
I need to extract some information from the Microsoft FSX Simulator through the TCP protocol using the IOCP software. I have checked it usig LabView environment and it works fine. But I need not to use a PC, and use only the Arduino connected to a router.
It is easy, my Arduino needs to write to the server (192.2.1.2 port 8090) the next command: "Arn.Inicio:Var419"
After that, I must to read the incommnig messages "Arn.Var419:xxxxxx"
Must I connect the Arduino like a clent? I have tried (see bellow) this code but It doesn't work, what do you think?
Thanks you very much & My best regards.
Pedro
client.println("Arn.Inicio:Var419"); //command from Arduino to FSX
client.println();
delay (10000);
rdx: // scan for responses from FSX
delay (100);
if (client.available()) {
char c = client.read();
Serial.print(c); //link TCP messages to serial (for debugging)
goto rdx;
}
void loop() {
client.println("Arn.Inicio:Var419"); //command from Arduino to FSX
client.println();
delay (10000);
rdx: // scan for responses from FSX
delay (100);
if (client.available()) {
char c = client.read();
Serial.print(c); //link TCP messages to serial (for debugging)
goto rdx;
}
}
The client.available() function returns the number of characters available to read. Read them in a while loop, rather than inventing your own. The goto statement has very little going for it here.
I have simplified the code, still not working:
You have some expectation of what the code should do. There is something that the code does. All we can tell from the information you have provided is that those two are not the same thing. We have a pretty good idea of what you expect it to do. What it actually does is a mystery.
You need to clear up that mystery if you expect help.
hadnt come across that library. Looks very simple and similar to the original ethernet shield.
Are you using the ENC28J60 shield with it??
Are you using a gateway?
Ive tried this and does not connect, maybe you can give me a hint.,
The code you posted looks like code for the wiznet 5100 chip. Below is what seems to be the ENC28J60 type coding. If you got ping to work, then maybe not.
#include "etherShield.h"
static uint8_t mymac[6] = {0x54,0x55,0x58,0x10,0x00,0x24};
static uint8_t myip[4] = {192,168,1,15};
static char baseurl[]="http://192.168.1.15/";
static uint16_t mywwwport =80; // listen port for tcp/www (max range 1-254)
zoomkat:
The code you posted looks like code for the wiznet 5100 chip. Below is what seems to be the ENC28J60 type coding. If you got ping to work, then maybe not.
With the library indicated at the beginning of the topic, is valid for ENC28J60.
please let me know if this code works for you cause i dont understand what is happening.
this is the one i used with an Arduino UNO.
I suppose that if you want to go out to the internet, without a router, through your PC, you need a crossover ethernet cable, take a look for this: kiranjose.com
Regards
no, i want to go out to the internet but i am using a router that has ip 192.168.1.1 thats why i need the gateway cause if not it does not find the router (same happens in my computers) i need to specify the routers ip.