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

  1. /* rexxserdev.library test program  used to debug function calls */
  2.  
  3. /* open the Rexx support library */
  4.  
  5. signal on error
  6. if ~show('L',"rexxsupport.library") then do
  7.    if addlib('rexxsupport.library',0,-30,0) then
  8.       say 'added rexxsupport.library'
  9.    else do;
  10.       say 'support library not available'
  11.       exit 10
  12.       end
  13.    end
  14.  
  15. /* open the Rexx serial device library */
  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. say serid()
  32. if ~sersetparms( dh, 9600, 8, 'N', 1 ) then say 'Parms not set'
  33. if ~serclear( dh ) then say 'buffer not clear'
  34. if serflush( dh, w ) then say 'write queue flushed'
  35. if serflush( dh, r ) then say 'read queue flushed'
  36. block = allocmem( 20 ) 
  37. addr = c2d( block )
  38. say 'memory block address =' addr
  39. query = SerQuery( dh )
  40. parse var query err rl stat
  41. if ~err then say 'query status valid'
  42. say 'number of characters in received buffer:' rl
  43. say 'status word in ASCII decimal:' stat
  44. say 'waiting for 5 characters from the remote'
  45. text = SerRead( dh, addr, 5 )
  46. say 'received:' text
  47. if ~freemem( block, 20 ) then say 'memory block not freed'
  48. text = 'send stuff out port again'
  49. say 'calling SerWrite'
  50. if ~serwrite( dh, text, length( text ) ) then say 'nothing written'
  51. say 'back from SerWrite'
  52. error:
  53. if serclose( dh ) then say 'serial device closed' 
  54. if remlib( 'rexxserdev.library' ) then say 'removed rexxserdev.library'
  55.