home *** CD-ROM | disk | FTP | other *** search
/ Club Amiga de Montreal - CAM / CAM_CD_1.iso / files / 324.lha / rexxserdev.library_v2.00 / testrecv.rexx < prev    next >
OS/2 REXX Batch file  |  1989-12-05  |  1KB  |  46 lines

  1. /* part of another serial port test program.                          */
  2. /* works best when connected to another computer via a null modem.    */
  3. /* first run testrecv in a one CLI; then run testsend in another CLI. */
  4.  
  5. /* open the Rexx support library */
  6.  
  7. signal on error
  8. if ~show('L',"rexxsupport.library") then do
  9.    if addlib('rexxsupport.library',0,-30,0) then
  10.       say 'added rexxsupport.library'
  11.    else do;
  12.       say 'support library not available'
  13.       exit 10
  14.       end
  15.    end
  16.  
  17. if ~show( 'L', "rexxserdev.library" ) then do
  18.    if addlib( 'rexxserdev.library', 0, -30, 0 ) then
  19.       say 'added rexxserdev.library'
  20.    else do;
  21.       say 'support library not available'
  22.       exit 10
  23.       end
  24.    end
  25.  
  26. libaddr = serlibbase()
  27. say 'serial library base =' libaddr
  28. dh = seropen( 'serial.device', 0 )
  29. if dh = "" then say 'serial device not opened'
  30. if serreset( dh ) then say 'serial device reset'
  31. if ~sersetparms( dh, 9600, 8, 'N', 1 ) then say 'Parms not set'
  32. if ~serclear( dh ) then say 'buffer not clear'
  33. block = allocmem( 80 ) 
  34. addr = c2d( block )
  35. say 'memory block address =' addr
  36. say "send a '~' to end"
  37. do until text = '~'
  38.    query = SerQuery( dh )
  39.    parse var query err rl stat
  40.    if rl > 0 then do; text = SerRead( dh, addr, rl ); call writech STDOUT, text; end;
  41.    end
  42. if ~freemem( block, 80 ) then say 'memory block not freed'
  43. error:
  44. if serclose( dh ) then say 'serial device closed'
  45. exit(0)
  46.