示例#1
0
// main
int main(int argc, char* argv[]){

  ComPortHandle comPort;
  int go = TRUE; 
  char* dev;
  char a;

  a='\0';

  dev=&a;
 
  if(argc<2){//No port specified at commandline so search for attached devices

    dev=scandev();
    if(strcmp(dev,"")!=0){
  
      //printf("Attempting to open port...%s\n",dev);
      comPort = OpenComPort(dev);

    }
    else{

      printf("Failed to find attached device.\n");
      return FALSE;

    }

  }
  else{//Open port specified at commandline

    printf("Attempting to open port...%s\n",argv[1]);
    comPort = OpenComPort(argv[1]);

  }

  if(comPort > 0){  

    //printf("Connected. \n\n");
    /*
    while(go){//continue until user chooses to exit
      unsigned int command;
      command = 0xc1;
      usleep(500000);//short sleep between commands
      go=CommandDialog(comPort,command);

    }*/
    unsigned int command;
    command = 0xd2;
    CommandDialog(comPort,command);
//    printf("EXITING\n"); 
    CloseComPort(comPort);

  }

  return 0;

}
示例#2
0
/* ----------------------------------Main----------------------------------- */
int main(int argc, char* argv[]){

  ComPortHandle comPort;
  int go = TRUE;
  char* dev;
  char a;

  a='\0';

  dev=&a;

  if(argc<2) {
    //No port specified at commandline so search for attached devices
    dev=scandev();
    if(strcmp(dev,"")!=0) {
      //printf("Attempting to open port...%s\n",dev);
      comPort = OpenComPort(dev);

    }
    else {
      printf("Failed to find attached device.\n");
      return FALSE;
    }
  }
  else {
    //Open port specified at commandline
    printf("Attempting to open port...%s\n",argv[1]);
    comPort = OpenComPort(argv[1]);
  }

  if(comPort > 0) {
    unsigned int command;
    command = 0xd2;
    CommandDialog(comPort,command);
    CloseComPort(comPort);
  }

  return 0;
}