Example #1
0
static void resetHandles(int handle1, int handle2)
{
  canStatus stat;
  int i = 0; // Turn off txAcks
  stat = canIoCtl(handle1, canIOCTL_SET_TXACK, &i, 4);
  if (stat != canOK) {
    Check("canIoCtl() failed to turn off txAcks", stat);
  }
    
  i = 1000; // Set resolution to the default 1 ms
  stat = canIoCtl(handle1, canIOCTL_SET_TIMER_SCALE, &i, 4);
  if (stat != canOK) {
    Check("canIoCtl() failed to set 1 ms resolution on the first channel", stat);
  }
     
  i = 1000; // Set resolution to the default 1 ms
  stat = canIoCtl(handle2, canIOCTL_SET_TIMER_SCALE, &i, 4);
  if (stat != canOK) {
    Check("canIoCtl() failed to set 1 ms resolution on the second channel", stat);
  }
  
  stat = kvTimeDomainDelete(mytd);
  if (stat != canOK) {
    Check("kvTimeDomainDelete() failed!", stat);
  }
}
Example #2
0
int canFlushReceiveQueue_(int handle) { return (int) canIoCtl(handle, canIOCTL_FLUSH_RX_BUFFER, NULL, 0); } 
Example #3
0
static void setupHandles(int handle1, int handle2)
{
  canStatus stat;
  int i = 1; // Turn on txAcks
  stat = canIoCtl(handle1, canIOCTL_SET_TXACK, &i, 4);
  if (stat != canOK) {
    Check("canIoCtl() failed to turn on txAcks on handle1", stat);
  }
  
  stat = canIoCtl(handle2, canIOCTL_SET_TXACK, &i, 4);
  if (stat != canOK) {
    Check("canIoCtl() failed to turn on txAcks on handle2", stat);
  }
  
  i = 10; // Set resolution to 10 us
  stat = canIoCtl(handle1, canIOCTL_SET_TIMER_SCALE, &i, 4);
  if (stat != canOK) {
    Check("canIoCtl() failed to set 10 us resolution on the first channel", stat);
  }
  
  i = 10; // Set resolution to 10 us
  stat = canIoCtl(handle2, canIOCTL_SET_TIMER_SCALE, &i, 4);
  if (stat != canOK) {
    Check("canIoCtl() failed to set 10 us resolution on the second channel", stat);
  }
  
  stat = kvTimeDomainCreate(&mytd);
  if (stat != canOK) {
    Check("kvTimeDomainCreate() failed!", stat);
  }
  
  stat = kvTimeDomainAddHandle(mytd, handle1);
  if (stat != canOK) {
    Check("kvTimeDomainAddHandle() failed for handle1!", stat);
  }
  
  stat = kvTimeDomainAddHandle(mytd, handle2);
  if (stat != canOK) {
    Check("kvTimeDomainAddHandle() failed for handle2!", stat);
  }
  
  stat = kvTimeDomainResetTime(mytd);
  if (stat != canOK) {
    Check("kvTimeDomainResetTime() failed!", stat);
  }
  
  stat = kvTimeDomainGetData(mytd, &kvtData, sizeof(kvTimeDomainData));
  if (stat != canOK) {
    Check("kvTimeDomainGetData() failed!", stat);
  }
  
  if (Verbose) {
    if (kvtData.nMagiSyncGroups > 1) {
      printf("WARNING: More than one magisync group. Consider connecting the"
             " interfaces\n         to the same USB root hub!\n");
    }
    if ((kvtData.nMagiSyncGroups + kvtData.nNonMagiSyncCards) == 1) {
      printf("INFO: The used channels are either MagiSynced or reside on "
             "the same\n      physical interface. Expect time stamps to be"
             " as good as the hardware\n      specification claims.\n");
    }
    else if ((kvtData.nMagiSyncGroups + kvtData.nNonMagiSyncCards) == 2) {
      printf("INFO: The used channels don't appear synchronized in any way."
             " In each test\n      the time stamp of the first message from"
             " both channels is used as\n      an offset subtracted from all"
             " subsequent timestamps. Hence, since\n      local clocks tend"
             " to drift, expect the time stamps to differ more\n      the"
             " longer the test runs.\n");
    }
    else {
      printf("WARNING: kvTimeDomainGetData reports an unexpected number of "
             "interfaces!\n         (magisynced = %u, others = %u)\n",
             kvtData.nMagiSyncGroups, kvtData.nNonMagiSyncCards);
    }
    if ((kvtData.nMagiSyncedMembers + kvtData.nNonMagiSyncedMembers) != 2) {
      printf("WARNING: kvTimeDomainGetData reports an unexpected number of"
             " members!\n         (magisynced = %u, others = %u)\n",
             kvtData.nMagiSyncedMembers, kvtData.nNonMagiSyncedMembers);
    }
  }
}