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

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