A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/ntruchsess/arduino_uip/commit/38c5e7e91e3cd380e7f4a4cb18da53d443b93b11 below:

add fast pollig for TCP (if feasable send outgoing max 10ms after las… · ntruchsess/arduino_uip@38c5e7e · GitHub

File tree Expand file treeCollapse file tree 5 files changed

+58

-16

lines changed

Filter options

Expand file treeCollapse file tree 5 files changed

+58

-16

lines changed Original file line number Diff line number Diff line change

@@ -226,6 +226,9 @@ UIPClient::_write(uip_userdata_t* u, const uint8_t *buf, size_t size)

226 226

goto newpacket;

227 227

}

228 228

ready:

229 +

#if UIP_CLIENT_TIMER >= 0

230 +

u->timer = millis()+UIP_CLIENT_TIMER;

231 +

#endif

229 232

return size-remain;

230 233

}

231 234

return -1;

Original file line number Diff line number Diff line change

@@ -55,6 +55,9 @@ typedef struct {

55 55

memhandle packets_in[UIP_SOCKET_NUMPACKETS];

56 56

memhandle packets_out[UIP_SOCKET_NUMPACKETS];

57 57

memaddress out_pos;

58 +

#if UIP_CLIENT_TIMER >= 0

59 +

unsigned long timer;

60 +

#endif

58 61

} uip_userdata_t;

59 62 60 63

class UIPClient : public Client {

Original file line number Diff line number Diff line change

@@ -45,7 +45,7 @@ uint8_t UIPEthernetClass::packetstate(0);

45 45

IPAddress UIPEthernetClass::_dnsServerAddress;

46 46

DhcpClass* UIPEthernetClass::_dhcp(NULL);

47 47 48 -

struct uip_timer UIPEthernetClass::periodic_timer;

48 +

unsigned long UIPEthernetClass::periodic_timer;

49 49 50 50

// Because uIP isn't encapsulated within a class we have to use global

51 51

// variables, so we can only have one TCP/IP stack per program.

@@ -220,22 +220,50 @@ UIPEthernetClass::tick()

220 220

}

221 221

}

222 222 223 -

if (uip_timer_expired(&periodic_timer))

223 +

unsigned long now = millis();

224 + 225 +

#if UIP_CLIENT_TIMER >= 0

226 +

boolean periodic = (long)( now - periodic_timer ) >= 0;

227 +

for (int i = 0; i < UIP_CONNS; i++)

228 +

{

229 +

#else

230 +

if ((long)( now - periodic_timer ) >= 0)

224 231

{

225 -

uip_timer_restart(&periodic_timer);

232 +

periodic_timer = now + UIP_PERIODIC_TIMER;

233 + 226 234

for (int i = 0; i < UIP_CONNS; i++)

227 235

{

228 -

uip_periodic(i);

229 -

// If the above function invocation resulted in data that

230 -

// should be sent out on the Enc28J60Network, the global variable

231 -

// uip_len is set to a value > 0.

232 -

if (uip_len > 0)

233 -

{

234 -

uip_arp_out();

235 -

network_send();

236 -

}

236 +

#endif

237 +

uip_conn = &uip_conns[i];

238 +

#if UIP_CLIENT_TIMER >= 0

239 +

if (periodic)

240 +

{

241 +

#endif

242 +

uip_process(UIP_TIMER);

243 +

#if UIP_CLIENT_TIMER >= 0

237 244

}

238 - 245 +

else

246 +

{

247 +

if ((long)( now - ((uip_userdata_t*)uip_conn->appstate)->timer) >= 0)

248 +

uip_process(UIP_POLL_REQUEST);

249 +

else

250 +

continue;

251 +

}

252 +

#endif

253 +

// If the above function invocation resulted in data that

254 +

// should be sent out on the Enc28J60Network, the global variable

255 +

// uip_len is set to a value > 0.

256 +

if (uip_len > 0)

257 +

{

258 +

uip_arp_out();

259 +

network_send();

260 +

}

261 +

}

262 +

#if UIP_CLIENT_TIMER >= 0

263 +

if (periodic)

264 +

{

265 +

periodic_timer = now + UIP_PERIODIC_TIMER;

266 +

#endif

239 267

#if UIP_UDP

240 268

for (int i = 0; i < UIP_UDP_CONNS; i++)

241 269

{

@@ -286,7 +314,7 @@ boolean UIPEthernetClass::network_send()

286 314

}

287 315 288 316

void UIPEthernetClass::init(const uint8_t* mac) {

289 -

uip_timer_set(&periodic_timer, CLOCK_SECOND / 4);

317 +

periodic_timer = millis() + UIP_PERIODIC_TIMER;

290 318 291 319

Enc28J60Network::init((uint8_t*)mac);

292 320

uip_seteth_addr(mac);

Original file line number Diff line number Diff line change

@@ -90,7 +90,7 @@ class UIPEthernetClass

90 90

static IPAddress _dnsServerAddress;

91 91

static DhcpClass* _dhcp;

92 92 93 -

static struct uip_timer periodic_timer;

93 +

static unsigned long periodic_timer;

94 94 95 95

static void init(const uint8_t* mac);

96 96

static void configure(IPAddress ip, IPAddress dns, IPAddress gateway, IPAddress subnet);

Original file line number Diff line number Diff line change

@@ -5,7 +5,8 @@

5 5

#define UIP_SOCKET_NUMPACKETS 5

6 6

#define UIP_CONF_MAX_CONNECTIONS 4

7 7 8 -

/* for UDP */

8 +

/* for UDP

9 +

* set UIP_CONF_UDP to 0 to disable UDP (saves aprox. 5kb flash) */

9 10

#define UIP_CONF_UDP 1

10 11

#define UIP_CONF_BROADCAST 1

11 12

#define UIP_CONF_UDP_CONNS 4

@@ -18,4 +19,11 @@

18 19

* if set to a number <= 0 connect will timeout when uIP does (which might be longer than you expect...) */

19 20

#define UIP_CONNECT_TIMEOUT -1

20 21 22 +

/* periodic timer for uip (in ms) */

23 +

#define UIP_PERIODIC_TIMER 250

24 + 25 +

/* timer to poll client for data after last write (in ms)

26 +

* set to -1 to disable fast polling and rely on periodic only (saves 100 bytes flash) */

27 +

#define UIP_CLIENT_TIMER 10

28 + 21 29

#endif

You can’t perform that action at this time.


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4