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 - comsend() send a character to a serial port http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
 comsend()           Send a character to a serial port
------------------------------------------------------------------------------
 Declaration
   io.hdr

 Syntax
   func byte comsend extern
   param value uint uPort, ;
         value byte bChar

 Arguments
   uPort is a serial port number.
   bChar is the character to send.

 Return
   A byte indicating the status of the port.

 Description
   The comsend() function sends a character to a serial port.

 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_comsend
   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_comsend()
   endproc

See Also: cominit() comrec()

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