//-------------------------------------------------------------------------- // The 'owSerialNum' function either reads or sets the SerialNum buffer // that is used in the search functions 'owFirst' and 'owNext'. // This function contains two parameters, 'serialnum_buf' is a pointer // to a buffer provided by the caller. 'serialnum_buf' should point to // an array of 8 unsigned chars. The second parameter is a flag called // 'do_read' that is TRUE (1) if the operation is to read and FALSE // (0) if the operation is to set the internal SerialNum buffer from // the data in the provided buffer. // // 'portnum' - number 0 to MAX_PORTNUM-1. This number is provided to // indicate the symbolic port number. // 'serialnum_buf' - buffer to that contains the serial number to set // when do_read = FALSE (0) and buffer to get the serial // number when do_read = TRUE (1). // 'do_read' - flag to indicate reading (1) or setting (0) the current // serial number. // void owSerialNum(int portnum, uchar *serialnum_buf, SMALLINT do_read) { short ROM[8],i; // check if reading or writing if (do_read) { ROM[0] = 0; } else { for (i = 0; i < 8; i++) ROM[i] = serialnum_buf[i]; } // call TMEX to read or set the current device TMRom(SessionHandle[portnum], StateBuffer[portnum], ROM); // place in 'serialnum_buf' if (do_read) { for (i = 0; i < 8; i++) serialnum_buf[i] = (uchar)ROM[i]; } }
/*---------------------------------------------------------------------- * Find the first device with a particular family */ short FindFirstFamily(short family, long session_handle) { short j; short ROM[9]; /* set up to find the first device with family 'family */ if (TMFamilySearchSetup(session_handle,&state_buffer,family) == 1) { /* get first device in list with the specified family */ if (TMNext(session_handle,state_buffer) == 1) { /* read the rom number */ ROM[0] = 0; TMRom(session_handle,state_buffer,ROM); /* check if correct type */ if ((family & 0x7F) == (ROM[0] & 0x7F)) { printf("Serial ROM ID: "); for (j = 7; j >= 0; j--) printf("%02X",ROM[j]); printf("\n\n"); return 1; } } } /* failed to find device of that type */ return 0; }