#include #include #include #include #include #include #include #define MY_PORT 7 int release_time[5]={0}; long int time; int system_start=0; int tasknum; void addr_handler(const unsigned char* data,unsigned char length, unsigned char src) { switch(data[0]) { case 't': tasknum = data[1]*256+data[2]; if(tasknum <10) printf("\tTask%d", tasknum ); break; case 'e': if( strcmp(data+1, "SystemStart") ==0) { system_start=time/20; printf("\nSetting system time to %d",system_start); } else if(strstr(data+1, "Deadline") != NULL) printf("\nInfo: %s=%d",data+1,tasknum); else if(strstr(data+1, "Ceiling") != NULL) printf("\nInfo: %s=%d",data+1,tasknum); else if(strstr(data+1, "Priority") != NULL) printf("\nInfo: %s=%d",data+1,tasknum); else printf("\t%s", &data[1] ); break; case 'i': time=data[1]*256*256*256+data[2]*256*256+data[3]*256+data[4]; printf("\n%ld", time/20-system_start ); break; default: printf( "unknown type for %c\n", data[0] ); } fflush( stdout ); } int main ( int argc, char *argv[] ) { if ( lnp_init ( 0, 0, 0, 0, 0 ) ) { perror ( "lnp_init" ); exit(1); } else { printf ( "init OK\nTimeSlot Task Event\n---------------" ); } lnp_addressing_set_handler (MY_PORT, addr_handler ); while(1); return 0; }