#include #include #include /* This simple cnet protocol source file demonstratess the use of cnet's debugging buttons, the Physical Layer, and checksums. The supplied function reboot_node() will first be called for each node. reboot_node() informs cnet that the node is interested in the EV_DEBUG0, EV_DEBUG1 and EV_PHYSICALREADY events. Strings are placed on the first and second debug buttons. When EV_DEBUG0 occurs, cnet calls send_reliable(), which will format a message in a frame and transmit that frame to the other node via link 1. As the message will be assumed to be a C string (ending in a '\0' byte), it is important to send the '\0' byte too (hence, strlen()+1 ). Similarly, when EV_DEBUG1 occurs, send_unreliable() is called. When EV_PHYSICALREADY occurs, cnet calls frame_arrived(), to read the frame from the Physical Layer and report its contents. */ #define MAX_FRAME 64 static char *fruit[] = { "apple", "pineapple", "banana", "tomato", "plum" }; #define NFRUITS (sizeof(fruit) / sizeof(fruit[0])) extern int random(void); static int seqno = 0; /* ---------------------------------------------------------------------- */ static void describe_frame(char *frame, unsigned int length) { char byte; int n; printf("[\""); for(n=0 ; n