Exemple #1
0
//==============================================================================
int g_InitFrameCounter(){
  int iValue;

  if( g_SysGrantIO( LPT_BASE ) ) return 1;
  if( g_SysGrantIO( ECP_AFIFO ) ) return 1;

  x_iCtlSave = PortInput(LPT_CONTROL);
  x_iEcpSave = PortInput(ECP_ECTRL);

  iValue = x_iEcpSave & 0x1F;  // keep lower 5 bits, clear upper 3
  iValue = iValue | 0x20;    // set mode 1 - bidirectional, PS2
  PortOutput( ECP_ECTRL, iValue);

  x_iPortIO_Granted = 1;
  x_iCounterStarted = 0;

  g_ResetFrameCounter();
  return 0;
}
Exemple #2
0
//==============================================================================
int CEyeTrack::ConnectISCAN(  ){
  int iRet;

  if( IsRunning() ) {
    CP_printf("Error in m_InitSerialThread()! Thread is already running.\n");
    return 1;
  }
  iRet = g_SysGrantIO( LPT_BASE );
  if( iRet ) {
    iPortIO_Granted = 0;
    printf("Error: Cannot grant I/O access, error: %d\n", iRet );
    return 1;
  }
 
  iPortIO_Granted = 1;
  PortOutput( LPT_CONTROL, RESET_ON);
  Sleep(1);
  PortOutput( LPT_CONTROL, GATE_OFF);
  Sleep(1);
  PortOutput( LPT_CONTROL, GATE_ON);


  CP_printf("Connecting to %s port\n", x_aszComNames[ m_iComPortIdx-1]);
  iRet = m_Serial.connect(x_aszComNames[ m_iComPortIdx-1], m_iBaudRate, m_iSerialParity);
  if(iRet) {
    CP_printf("Error in m_InitSerialThread, m_Serial.connect() failed\n");
    return 1;
  }

  m_ReadCount = 0;
  m_iMissCount = 0;
  m_nMissedFrames = 0;
  m_iPrevFrame = 0;
  m_iReportSync = 1;  // report next sync
  // Init sliding buffer
  SetBuffer(sizeof(IScanFrameStruct), ISCAN_BUFFER_SIZE);
  ResetBuffer();
  ResetTime();
  m_StartReadingThread( ); 
  if( !IsRunning() ) {
    CP_printf("Error in m_InitSerialThread()! CreateThread() failed.\n");
    PortOutput( LPT_CONTROL, GATE_OFF);
    RemoveBuffer();
    return 1;
  }
  CP_printf("Connected ISCAN\n");
  CP_printf("Expected number of parameters: %d\n", N_DATA_ITEMS);
  return 0;
}