Kap 1 Posted June 4, 2015 Share Posted June 4, 2015 Hi, I am using Energia ethernet library for Ti Tiva c 129 Launchpad. I wrote a simple program in Energia that gets a byte from stream and sends back two bytes. It seems there is lag when I send bytes back from Ti board. Here is my code. byte mac[] = {0x00, 0x0A, 0xB7, 0x52, 0xBA, 0x16 }; IPAddress ip(192,168,1,192); IPAddress gateway(192,168,1,1); IPAddress subnet(255,255,255,0); EthernetServer server(80); EthernetClient client; void setup() { Ethernet.begin(mac, ip, gateway, subnet); server.begin(); Serial.begin(9600); } void loop() { byte buf[2]; buf[0] = 'O'; buf[1] = 'K'; client = server.available(); if (client.available()) { char c = client.read(); if (c == 'S'){ Serial.print("A"); client.write(buf, 2); } } } And i am sending data from a simple vb program like this Dim d As Byte() data = New [Byte](2) {} d = System.Text.Encoding.ASCII.GetBytes("S") stream.Write(d, 0, d.Length) While stream.DataAvailable = False End While stream.Read(data, 0, data.Length) d = System.Text.Encoding.ASCII.GetBytes("S") stream.Write(d, 0, d.Length) While stream.DataAvailable = False End While stream.Read(data, 0, data.Length) d = System.Text.Encoding.ASCII.GetBytes("S") stream.Write(d, 0, d.Length) While stream.DataAvailable = False End While stream.Read(data, 0, data.Length) MessageBox.Show("Test") It takes more than half a second for "Test" message to appear on the screen using Ti Tiva C129 board and Energia. If we send data byte by byte like this: client.write('O'); client.write('K'); It works fine. I tried the same program with Arduino Mega and it works fine regardless of how we send it. When using Arduino Mega it takes less than maybe 50 milliseconds for message to appear on the screen Quote Link to post Share on other sites
L.R.A 78 Posted August 21, 2015 Share Posted August 21, 2015 Hi, @@KapDid you get any improvements? I want to receive by ethernet a streaming of bytes and I'm hopping that energia ethernet library is not to slow so that I don't need to go full tivaware Quote Link to post Share on other sites
Kap 1 Posted August 21, 2015 Author Share Posted August 21, 2015 Hi LRA, There may be an issue with the energia ethernet library. This is what I ended up doing: Modify the EthernetClient.cpp file and add a custom write function. It is the same as the one already there but comment out this "if (cs->mode)" Declare the function in the EthernetClient.h as "virtual size_t write_1(const uint8_t *buf, size_t size);" Or simply modify the the existing write function and replace the code with this size_t EthernetClient::write_1(const uint8_t *buf, size_t size) { uint32_t i = 0, inc = 0; boolean stuffed_buffer = false; struct tcp_pcb * cpcb = (tcp_pcb*)cs->cpcb; /* cs->cpcb may change to NULL during interrupt servicing */ if (!cpcb) return 0; // Attempt to write in 1024-byte increments. while (stuffed_buffer == false) { err_t err = tcp_write(cpcb, buf, size, (0x01)); if (err != ERR_MEM) { tcp_output(cpcb); //delay(1); //new addition stuffed_buffer = true; } else { if (stuffed_buffer == false){ tcp_output(cpcb); //delay(1); //new addition stuffed_buffer = false; }else{ //delay(1); } } //delay(1); } return size; } bluehash 1 Quote Link to post Share on other sites
L.R.A 78 Posted August 21, 2015 Share Posted August 21, 2015 Thank you very much @@Kap.Unfortunately I do not have here the board to test it out and i'm only gonna have it like in the 31st.I was hopping to reach the 10Mbps or the 8Mbps that I've seen people have in arduino.I wonder if this speed problem was fixed in other energia versions 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.