예제 #1
0
/* reads digital port  */
void usbDIn_USBTEMP(int fd, __u8* value)
{
  PMD_SendOutputReport(fd, DIN, 0, 0, FS_DELAY);
  PMD_GetInputReport(fd, DIN, value, 1, FS_DELAY);
  PMD_GetInputReport(fd, DIN, value, 1, FS_DELAY);
  return;
}
예제 #2
0
int usbGetItem_USBTEMP(HIDInterface* hid, __u8 item, __u8 subitem, void* value)
{
    __u8 cmd[5];  // The returning data could be one byte or a 4 byte float.

    struct t_getItem {
        __u8 reportID;
        __u8 item;
        __u8 subitem;
    } getItem;

    if ( item > 3 ) {
        printf("Error: usbGetItem_USBTEMP  Item = %d too large.\n", item);
    }

    getItem.reportID = GET_ITEM;
    getItem.item = item;
    getItem.subitem = subitem;

    PMD_SendOutputReport(hid, 0, (__u8 *) &getItem, sizeof(getItem), FS_DELAY);

    switch (subitem) {
    case SENSOR_TYPE:
    case CONNECTION_TYPE:
    case FILTER_RATE:
    case EXCITATION:
    case CH_0_TC:
    case CH_1_TC:
    case CH_0_GAIN:
    case CH_1_GAIN:
        PMD_GetInputReport(hid, 0, cmd, 2, FS_DELAY);
        memcpy(value, &cmd[1], 1);  // one byte value
        return 1;
        break;
    case VREF:
    case I_value_0:
    case I_value_1:
    case I_value_2:
    case V_value_0:
    case V_value_1:
    case V_value_2:
    case CH_0_COEF_0:
    case CH_1_COEF_0:
    case CH_0_COEF_1:
    case CH_1_COEF_1:
    case CH_0_COEF_2:
    case CH_1_COEF_2:
    case CH_0_COEF_3:
    case CH_1_COEF_3:
        PMD_GetInputReport(hid, 0, cmd, 5, FS_DELAY);
        memcpy(value, &cmd[1], 4);
        return 4;
        break;
    default:
        printf("Error usbGetItem_USBTEMP: subitem = %#x unknown\n", subitem);
        return -1;
    }
    return 0;
}
예제 #3
0
int usbReadCode_USBTEMP(HIDInterface* hid, __u32 address, __u8 count, __u8 data[])
{
    struct t_readCode {
        __u8 reportID;
        __u8 address[3];
        __u8 count;
    } readCode;

    struct t_readCodeI {
        __u8 reportID;
        __u8 data[62];
    } readCodeI;

    int bRead;  // bytes read

    if ( count > 62 ) count = 62;

    readCode.reportID = READ_CODE;
    memcpy(readCode.address, &address, 3);   // 24 bit address
    readCode.count = count;
    PMD_SendOutputReport(hid, 0, (__u8 *) &readCode, sizeof(readCode), FS_DELAY);

    bRead = PMD_GetInputReport(hid, 0,  (__u8 *) &readCodeI, count+1, FS_DELAY);
    memcpy(data, readCodeI.data, count);
    return bRead;
}
예제 #4
0
void usbReadMemory_USBTEMP(HIDInterface* hid, __u16 address, __u8 type, __u8 count, __u8 *memory)
{
    struct t_readMemory {
        __u8 reportID;
        __u16 address;
        __u8 type;     // 0 = main microcontroller  1 = isolated microcontroller
        __u8 count;
    } readMemory;

    struct t_readMemoryI {
        __u8 reportID;
        __u8 memory[62];
    } readMemoryI;

    if ( count > 62 && type == 0) count = 62;  // 62 bytes max for main microcontroller
    if ( count > 60 && type == 1) count = 60;  // 60 bytes max for isolated microcontroller

    readMemory.reportID = MEM_READ;
    readMemory.type = type;
    readMemory.address = address;
    readMemory.count = count;

    PMD_SendOutputReport(hid, 0, (__u8 *) &readMemory, sizeof(readMemory), FS_DELAY);
    PMD_GetInputReport(hid, 0,  (__u8 *) &readMemoryI, count+1, FS_DELAY);
    memcpy(memory, readMemoryI.memory, count);
}
예제 #5
0
void usbTinScan_USBTEMP(HIDInterface* hid, __u8 start_chan, __u8 end_chan, __u8 units, float value[])
{
    int nchan;
    struct t_tinScan {
        __u8 reportID;
        __u8 start_chan;  // the first channel to return 0-7
        __u8 end_chan;    // the last channel to return 0-7
        __u8 units;       // 0 - temperature, 1 - raw measurement
    } tinScan;

    struct t_tinScan_val {
        __u8 reportID;
        __u8 value[32];  // maximum number of measurements
    } tinScan_val;

    tinScan.reportID = TIN_SCAN;
    tinScan.start_chan = start_chan;
    tinScan.end_chan = end_chan;
    tinScan.units = units;
    nchan = (end_chan - start_chan + 1);

    PMD_SendOutputReport(hid, 0, (__u8*) &tinScan, sizeof(tinScan), FS_DELAY);
    PMD_GetInputReport(hid, 0, (__u8*) &tinScan_val, nchan*sizeof(float)+1, FS_DELAY);
    memcpy(value, tinScan_val.value, nchan*sizeof(float));
}
예제 #6
0
void usbTin_USBTEMP(HIDInterface* hid, __u8 channel, __u8 units, float *value)
{

    /*
      This command reads the value from the specified input channel.  The return
      value is a 32-bit floating point value in the units configured fro the
      channel.  CJC readings will always be in Celsius.
    */

    struct t_tin {
        __u8 reportID;
        __u8 channel;  // 0 - 7
        __u8 units;    // 0 - temperature, 1 - raw measurement
    } tin;

    struct t_tin_val {
        __u8 reportID;
        __u8 value[4];
    } tin_val;

    tin.reportID = TIN;
    tin.channel = channel;
    tin.units = units;

    PMD_SendOutputReport(hid, 0, (__u8*) &tin, sizeof(tin), FS_DELAY);
    PMD_GetInputReport(hid, 0, (__u8*) &tin_val, sizeof(tin_val), FS_DELAY);
    memcpy(value, tin_val.value, 4);
}
예제 #7
0
__u8 usbGetStatus_USBTEMP(int fd)
{
  __u8 status;

  PMD_SendOutputReport(fd, GET_STATUS, 0, 0, FS_DELAY);
  PMD_GetInputReport(fd, GET_STATUS, (__u8 *) &status, sizeof(status), FS_DELAY);
  return status;
}
예제 #8
0
/* reads digital bit  */
void usbDInBit_USBTEMP(int fd, __u8 bit_num, __u8* value)
{
  __u8 cmd[1];

  cmd[0] = bit_num;

  PMD_SendOutputReport(fd, DBIT_IN, cmd, sizeof(cmd), FS_DELAY);
  PMD_GetInputReport(fd, DBIT_IN, value, sizeof(*value), FS_DELAY);
 
  return;
}
예제 #9
0
__u8 usbGetStatus_USBTEMP(HIDInterface* hid)
{
    struct t_statusReport {
        __u8 reportID;
        __u8 status;
    } statusReport;

    statusReport.reportID = GET_STATUS;
    PMD_SendOutputReport(hid, 0, &statusReport.reportID, 1, FS_DELAY);
    PMD_GetInputReport(hid, 0, (__u8*) &statusReport, sizeof(statusReport), FS_DELAY);
    return statusReport.status;
}
예제 #10
0
void usbTinScan_USBTEMP(int fd, __u8 start_chan, __u8 end_chan, __u8 units, float value[])
{
  int nchan;
  __u8 cmd[3];

  nchan = (end_chan - start_chan + 1);

  cmd[0] = start_chan;  // the first channel to return 0-7
  cmd[1] = end_chan;    // the last channel to return 0-7
  cmd[2] = units;       // 0 - temperature, 1 - raw measurement

  PMD_SendOutputReport(fd, TIN_SCAN, cmd, sizeof(cmd), FS_DELAY);
  PMD_GetInputReport(fd, TIN_SCAN, (__u8*) value, nchan*sizeof(float), FS_DELAY);
}
예제 #11
0
__u8  usbGetBurnoutStatus_USBTEMP(int fd, __u8 mask)
{
    /*
     This command returns the status of burnout detection for thermocouple channels.  The
     return value is a bitmap indicating the burnout detection status for all 8 channels.
     Individual bits will be set if an open circuit has been detected on that channel.  The
     bits will be cleared after the call using the mask that is passed as a parameter. If
     a bit is set, the corresponding bit in the status will be left at its current value.
  */

  __u8 status;
  
  PMD_SendOutputReport(fd, GET_BURNOUT_STATUS, 0, 0, FS_DELAY);
  PMD_GetInputReport(fd, GET_BURNOUT_STATUS,  &status, sizeof(status), FS_DELAY);
  return (status & mask);
}
예제 #12
0
void usbReadMemory_USBTEMP(int fd, __u16 address, __u8 type, __u8 count, __u8 *memory)
{
  struct t_arg {
    __u16 address;
    __u8 type;     // 0 = main microcontroller  1 = isolated microcontroller
    __u8 count;
  } arg;
  if ( count > 62 && type == 0) count = 62;  // 62 bytes max for main microcontroller
  if ( count > 60 && type == 1) count = 60;  // 60 bytes max for isolated microcontroller
  arg.type = type;
  arg.address = address;
  arg.count = count;

  PMD_SendOutputReport(fd, MEM_READ, (__u8 *) &arg, sizeof(arg), FS_DELAY);
  PMD_GetInputReport(fd, MEM_READ,  memory, count, FS_DELAY);
}
예제 #13
0
int usbReadCode_USBTEMP(int fd, __u32 address, __u8 count, __u8 data[])
{
  struct t_arg {
    __u8 address[3];
    __u8 count;
  } arg;

  int bRead;

  if ( count > 62 ) count = 62;  

  memcpy(&arg.address[0], &address, 3);   // 24 bit address
  arg.count = count;
  PMD_SendOutputReport(fd, READ_CODE, (__u8 *) &arg, sizeof(arg), FS_DELAY);
  bRead = PMD_GetInputReport(fd, READ_CODE,  data, count, FS_DELAY);
  return bRead;
}
예제 #14
0
void usbTin_USBTEMP(int fd, __u8 channel, __u8 units, float *value)
{

  /*
    This command reads the value from the specified input channel.  The return
    value is a 32-bit floating point value in the units configured fro the
    channel.  CJC readings will always be in Celsius.
  */
  
  __u8 cmd[2];

  cmd[0] = channel; // 0 - 7
  cmd[1] = units;   // 0 - temperature, 1 - raw measurement

  PMD_SendOutputReport(fd, TIN, cmd, sizeof(cmd), FS_DELAY);
  PMD_GetInputReport(fd, TIN, (__u8*) value, sizeof(float), FS_DELAY);
}
예제 #15
0
void usbGetItem_USBTEMP(int fd, __u8 item, __u8 subitem, void *value)
{
    int size;
  __u8 cmd[2];

  cmd[0] = item;
  cmd[1] = subitem;

  switch (subitem) {
    case SENSOR_TYPE:
    case CONNECTION_TYPE:
    case FILTER_RATE:
    case EXCITATION:
    case CH_0_TC:
    case CH_1_TC:
    case CH_0_GAIN:
    case CH_1_GAIN:
      size = 1;
      break;
    case VREF:
    case I_value_0:
    case I_value_1:
    case I_value_2:
    case V_value_0:
    case V_value_1:
    case V_value_2:
    case CH_0_COEF_0:
    case CH_1_COEF_0:
    case CH_0_COEF_1:
    case CH_1_COEF_1:
    case CH_0_COEF_2:
    case CH_1_COEF_2:
    case CH_0_COEF_3:
    case CH_1_COEF_3:
      size = 4;
      break;
    default:
      printf("Error usbGetItem_USBTEMP: subitem = %#x unknown\n", subitem);
      return;
  }

  PMD_SendOutputReport(fd, GET_ITEM,  cmd, sizeof(cmd), FS_DELAY);
  PMD_GetInputReport(fd, GET_ITEM,  value, size, FS_DELAY);
}
예제 #16
0
__u8  usbGetBurnoutStatus_USBTEMP(HIDInterface* hid, __u8 mask)
{
    /*
       This command returns the status of burnout detection for thermocouple channels.  The
       return value is a bitmap indicating the burnout detection status for all 8 channels.
       Individual bits will be set if an open circuit has been detected on that channel.  The
       bits will be cleared after the call using the mask that is passed as a parameter. If
       a bit is set, the corresponding bit in the status will be left at its current value.
    */

    struct t_burnoutStatus {
        __u8 reportID;
        __u8 status;
    } burnoutStatus;

    burnoutStatus.reportID = GET_BURNOUT_STATUS;

    PMD_SendOutputReport(hid, 0, (__u8 *) &burnoutStatus, 1, FS_DELAY);
    PMD_GetInputReport(hid, 0, (__u8 *) &burnoutStatus,  sizeof(burnoutStatus), FS_DELAY);
    return (burnoutStatus.status & mask);
}