Exemplo n.º 1
0
int main()
{
    HANDLE fd; 
    DCB OldConf;
    char cad[16]="Enviando Texto";
    int n;
    
    fd=Open_Port("COM1");               // Abre el puerto serie
                                        // fd=Open_Port("/dev/ttyS0"); 
    
    OldConf=Get_Configure_Port(fd);     // guardo la configuracion del puerto 
    
    Configure_Port(fd,B115200,"8N1");   // Configuro el puerto serie 
    
                                        // Bloqueante por defecto, pero tambien
                                        // se puede usar
                                        // IO_Blocking(fd,TRUE); 
    
    n=Write_Port(fd,cad,16);            // Escribo en el puerto serie
    
    while(Kbhit_Port(fd)<16);           // Espero a leer hasta que se tengan
                                        // 16 bytes en el buffer de entrada 

    n=Read_Port(fd,cad,16);             // Leo el puerto serie 
    printf(cad);                        // Muestro los datos
    
    Set_Configure_Port(fd,OldConf);     // Restituyo la antigua configuracion 
                                        // del puerto 

    Close_Port(fd);                     // Cierro el puerto serie 
    
    printf("\nPresione ENTER para terminar\n");
    getchar();
    
    return 0;
}
Exemplo n.º 2
0
*cdecl cpx_init( XCPB *Xcpb )
{
    OBJECT *tree;
    int    port;
    int    temp_port;
    
    xcpb = Xcpb;
    if( xcpb->booting )
    {
        /* Read in defaults and set the options */

        store = ( BUFFER *)(*xcpb->Get_Buffer)();
        Modem = save_vars;
        
        Set_Machine_Code();
	Set_Number_Of_Ports();        
	
        for( port = 0; port < Num_Ports; port++ )
        {
	   Write_Port( port, store );
	   store++;
        }
        Modem.cur_port = Set_Active_Port( Modem.cur_port );
        return( ( CPXINFO *)TRUE );  
    }
    else
    {
      appl_init();
      AES_Version = _GemParBlk.global[0];
      
      if( !xcpb->SkipRshFix )
           (*xcpb->rsh_fix)( NUM_OBS, NUM_FRSTR, NUM_FRIMG, NUM_TREE,
           		    rs_object, rs_tedinfo, rs_strings, rs_iconblk,
           		    rs_bitblk, rs_frstr, rs_frimg, rs_trindex,
           		    rs_imdope );


      Supexec( Get_OS );
      tree = ( OBJECT *)rs_trindex[ RS232 ];
      Disable( PORT );
      Set_Machine_Code();
      (( IsTT() || IsSTE() ) ? ( Enable( PORT ) ) : ( Disable( PORT ) ) );
      Set_Number_Of_Ports();
      store = ( BUFFER *)(*xcpb->Get_Buffer)();
      
      Modem = save_vars;	/* Get the Defaults and fill up all 4 ports with info */
      
      /* Get the ACTUAL system values for as many ports as possible.*/
      temp_port = Get_Active_Port();
      for( port = 0; port < Num_Ports; port++ )
      {
	Read_Port( port, store );
	store++;      
      }
      Modem.cur_port = Set_Active_Port( temp_port );
      push_data();
 
      open_vwork();
      close_vwork();
      gl_ncolors = work_out[13];

      if( !xcpb->SkipRshFix )
      {
        if(( AES_Version >= 0x0330 )
         && ( gl_ncolors > LWHITE ))
        {
          tree  = (OBJECT *)rs_trindex[RS232];
	  MakeActivator( RS232, SAVE );
	  MakeActivator( RS232, RS232OK );
	  MakeActivator( RS232, RS232CAN );
        }
      }   
      
      
      
      cpxinfo.cpx_call   = cpx_call;
      cpxinfo.cpx_draw   = NULL;
      cpxinfo.cpx_wmove  = NULL;
      cpxinfo.cpx_timer  = NULL;
      cpxinfo.cpx_key    = NULL;
      cpxinfo.cpx_button = NULL;
      cpxinfo.cpx_m1 	 = NULL;
      cpxinfo.cpx_m2	 = NULL;
      cpxinfo.cpx_hook   = NULL;
      cpxinfo.cpx_close  = NULL;             
      return( &cpxinfo );
    }
}