home *** CD-ROM | disk | FTP | other *** search
- /**********************************************************************/
- /* */
- /* CSAMP Sample Program, Support Procedures */
- /* */
- /**********************************************************************/
-
- #include <stdarg.h>
- #include <stdlib.h>
- #include <stdio.h>
- #include <string.h>
- #include <ctype.h>
- #include <rmxc.h>
-
- /* Forward declarations */
- extern void delay_fine();
- extern void delay();
-
- /**********************************************************************/
- /* C_DATA */
- /**********************************************************************/
- void c_data()
- {
- char array1[12];
- int i;
-
- struct struc1_type {
- char xchar;
- short int xshort;
- int xint;
- unsigned int xunint;
- } struc1;
-
- struct customertype {
- char name[8];
- char phone[7];
- struct customertype *linkfor;
- } customerlist[3];
-
- struct customertype *customer,*oldcust;
-
- static char *name_init[3] = {
- "Beth ",
- "Steve ",
- "Becky "
- };
-
- static char *phone_init[3] = {
- "5551234",
- "5555678",
- "5554321"
- };
- /* Format for a simple (unreal) Ethernet packet
-
- +----------------------------------------------------+
- | P | Dest | Source | Type | Data | CRC |
- +----------------------------------------------------+
- 31 28 24 20 17 1 0
- */
-
- struct enet_pkt_type {
- unsigned int crc:2;
- unsigned int data:16;
- unsigned int pkt_type:3;
- unsigned int source_addr:4;
- unsigned int dest_addr:4;
- unsigned int preamble:3;
- } enet_pkt;
-
- for( i = 0 ; i <= 11 ; i++ )
- array1[i]= (char)i + ' ';
-
- struc1.xchar = '!';
- struc1.xshort = -10;
- struc1.xint = 1;
- struc1.xunint = 6;
-
- enet_pkt.data = 4096;
- enet_pkt.crc = 1;
- enet_pkt.pkt_type = 3;
- enet_pkt.source_addr = 10;
- enet_pkt.dest_addr = 12;
- enet_pkt.preamble = 7;
-
- customer = NULL;
- for(i=0;i<=2;i++){
- oldcust = customer;
- customer = &customerlist[i];
- strcpy(customerlist[i].name,name_init[i]);
- strcpy(customerlist[i].phone,phone_init[i]);
- customer->linkfor = NULL;
- if (oldcust != NULL)
- oldcust->linkfor = customer;
- }
- }
-
-
- void delay (msecs)
- int msecs;
- {
- int sleep100; /* Each unit of "sleep100" is 100 msecs. */
-
- sleep100 = msecs / 100;
-
- for (; sleep100 >= 0; sleep100--)
- delay_fine (10); /* delay_fine(10) delays for 100 msecs. */
- }
-
-
- static void delay_fine (count)
- int count;
- {
- WORD exception;
-
- if (count != 0) {
- rqsleep (1, &exception); /* One rqsleep unit is 10 msecs. */
- delay_fine (--count ); /* Call self recursively. */
- }
- }
-