/** * This function should be called when a packet is ready to be read * from the interface. It uses the function low_level_input() that * should handle the actual reception of bytes from the network * interface. Then the type of the received packet is determined and * the appropriate input function is called. * * @param netif the lwip network interface structure for this ethernetif */ void ethernetif_input(void *arg) { struct eth_hdr *ethhdr; struct pbuf *p; struct netif *netif = (struct netif *)arg; if(net_dev_id==ACORAL_DEV_ERR_ID) return; do { /* move received packet into a new pbuf */ //p = hw_getPacket(/*netif,*/ &flag); acoral_dev_read(net_dev_id, &p, 0, 0,0); /* no packet could be read, silently ignore this */ if (p == NULL) continue; /* points to packet payload, which starts with an Ethernet header */ ethhdr = p->payload; switch (htons(ethhdr->type)) { /* IP or ARP packet? */ case ETHTYPE_IP: case ETHTYPE_ARP: #if PPPOE_SUPPORT /* PPPoE packet? */ case ETHTYPE_PPPOEDISC: case ETHTYPE_PPPOE: #endif /* PPPOE_SUPPORT */ /* full packet send to tcpip_thread to process */ if (netif->input(p, netif)!=ERR_OK) { LWIP_DEBUGF(NETIF_DEBUG, ("ethernetif_input: IP input error\n")); pbuf_free(p); // acoral_delay_self(400); p = NULL; } break; default: pbuf_free(p); p = NULL; break; } }while(1); }
static int TS_Read( int *px, int *py, int *pb ) { acoral_dev_read(ts_id,&ts_info,0,0,0); *px=ts_fix.xfactor*ts_info.x+ts_fix.xoffset; *py=ts_fix.yfactor*ts_info.y+ts_fix.yoffset; if(ts_info.event==ACORAL_TS_DOWN) *pb=MOUSE_EVENT_LBUTTON_DOWN; else *pb=MOUSE_EVENT_LBUTTON_UP; return 1; }
static int TS_ReadRaw( int *px, int *py, int *pb ) { acoral_dev_read(ts_id,&ts_info,0,0,0); *px=ts_info.x; *py=ts_info.y; if(ts_info.event==ACORAL_TS_DOWN) *pb=MOUSE_EVENT_LBUTTON_DOWN; else *pb=MOUSE_EVENT_LBUTTON_UP; return 1; }
int BDKB_Read( BYTE* btScanCode, BYTE* btPressed ) { int ret; int size; if(kb_id<0){ acoral_suspend_self(); } size = sizeof(acoral_kb_info); ret = acoral_dev_read(kb_id,&buf,size,0,0); if(ret == size){ *btScanCode = buf.key_code; *btPressed = buf.event; return 1; } else{ printf("read keyboard error\n"); return 0; } return 1; }