blueminerals 1 Posted January 9, 2021 Share Posted January 9, 2021 Running windows 10 and a TM4C1294 launchpad ethernet server with a tplink router inbetween the pc and the launchpad. When I try to test this with using putty telenet at 192.168.180.164 port 80 without typing anything, I get garbage characters like this : inByte: ÿ inByte: ÿ inByte: ÿ inByte: ÿ inByte: ÿ inByte: ÿ inByte: ÿ inByte: ÿ inByte: ÿ inByte: ÿ inByte: ÿ inByte: ÿ inByte: ÿ inByte: ÿ Why is this occurring? I can stop it by screening for ascii characters with : if((inByte > 47) and (inByte < 123). #include <Energia.h> #include <SPI.h> #include <Ethernet.h> #include <EthernetServer.h> #include <EthernetClient.h> char inByte; uint8_t mac[6]; EthernetServer ctrlserver = EthernetServer(80); // for receiving commands and sending responses. tcp. EthernetClient client; void setup() { // start serial port. Serial.begin(115200); if( Ethernet.begin(mac) ) { Serial.print("DHCP Hand Controller is at IP: "); Serial.println(Ethernet.localIP()); ctrlserver.begin(); Serial.print("The gateway IP address is: "); Serial.println(Ethernet.gatewayIP()); Serial.print("The subnet mask is: "); Serial.println(Ethernet.subnetMask()); } else { // Use a static, hard-coded IP address. byte gateway[] = { 192, 168, 180, 150 }; // the subnet: byte subnet[] = { 255, 255, 255, 0 }; byte ip[] = { 192, 168, 180, 164}; // // Note: ethernet.begin() ignores whatever value for MAC // address you give it; it uses the flashed MAC. //Ethernet.begin(mac, ip, gateway, subnet); Ethernet.begin(mac, ip); //Ethernet.begin(NULL, ip); ctrlserver.begin(); Serial.print("arm Controller is at IP: "); Serial.println(Ethernet.localIP()); } // done if using hard-coded IP. Serial.println("connecting..."); // put your setup code here, to run once: } void loop() { // if an incoming client connects, there will be bytes available to read: client = ctrlserver.available(); Ethernet.maintain(); if (client == true) { // read bytes from the incoming client and write them back // to any clients connected to the server: inByte = client.read(); ctrlserver.write(inByte); //for test Serial.print("inByte: "); Serial.println(inByte); // examine the serial stream for commands and call subroutines } } Quote Link to post Share on other sites
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.