Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Force 4.0 Reference - cominit() initialize serial port http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
 cominit()           Initialize serial port
------------------------------------------------------------------------------
 Declaration
   io.hdr

 Syntax
   func byte cominit extern
   param value uint uPort, ;
         value byte bParameters

 Arguments
   uPort is a serial port number.
   bParameters contain the initialization parameters.

 Return
   A byte describing the status of the port after initialization.

 Description
   The cominit() function initializes a serial port for communications.
   See the Serial communications table for macros defined for ports and
   parameters.

 Example
   #define EXAMPLE_IO
   #include example.hdr

   // A simple terminal program
   
   #define PORT_USED COM2
   
   proc Terminal
   para value uint nPort
   vardef
      uint uKey
   enddef
   do while .t.
      if comready( nPort )
         ?? chr( comrec( nPort ) )
      else
         uKey := inkey()
         do case
         case uKey == 0
         case uKey == K_ESC
            exit
         otherwise
            ?? chr( uKey )
            comsend( nPort, uKey )
         endcase
      endif
   enddo
   endproc
   
   proc Test_cominit
   clear
   ? "Press Esc to finish"
   cominit( PORT_USED, COM_2400 + COM_NOPARITY + COM_STOP1 + COM_CHR8 )
   ? "COM port", istr( PORT_USED + 1 ), "status", comstatus( PORT_USED )
   comsend( PORT_USED, K_BS )      // send a backspace to initialize port
   ?? comstatus( PORT_USED )
   ?
   Terminal( PORT_USED )
   endproc

   proc main
   Test_cominit()
   endproc

See Also: Serial communications table comready() comstatus()

Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson