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 - combios() execute a serial port command http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
 combios()           Execute a serial port command
------------------------------------------------------------------------------
 Declaration
   io.hdr

 Syntax
   func uint combios extern
   param value byte bCommand, ;
         value uint uPort, ;
         value byte bParameter

 Arguments
   bCommand is the serial port command to execute.
   uPort is a serial port number.
   bParameter is a parameter specific for the command.

 Return
   An uint numeric whose contents depends on the command requested.

 Description
   The combios() function provides direct interface to the BIOS 14h
   interrupt, for data communications via serial ports.

   See the Serial communications table for macros defined for commands,
   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 testbit( hibyte( combios( COM_STATUS, nPort, 0 ) ), 0 )
         ?? chr( lobyte( combios( COM_RECEIVE, nPort, 0 ) ) )
      else
         uKey := inkey()
         do case
         case uKey == 0
         case uKey == K_ESC
            exit
         otherwise
            ?? chr( uKey )
            combios( COM_SEND, nPort, uKey )
         endcase
      endif
   enddo
   endproc
   
   proc Test_combios
   clear
   ? "Press Esc to finish"
   combios( COM_INIT, PORT_USED, ;
      COM_2400 + COM_NOPARITY + COM_STOP1 + COM_CHR8 )
   ? "COM port", istr( PORT_USED + 1 ), "status", ;
      hibyte( combios( COM_STATUS, PORT_USED, 0 ) )
   combios( COM_SEND, PORT_USED, K_BS ) // send a backspace to initialize port
   ?? hibyte( combios( COM_STATUS, PORT_USED, 0 ) )
   ?
   Terminal( PORT_USED )
   endproc

   proc main
   Test_combios()
   endproc

See Also: Serial communications table

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