home *** CD-ROM | disk | FTP | other *** search
/ Club Amiga de Montreal - CAM / CAM_CD_1.iso / files / 310.lha / rexxserdev.library_v1.08 / testserial.rexx < prev   
OS/2 REXX Batch file  |  1980-12-05  |  2KB  |  54 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, 1 ) 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. if seropen() then say 'serial device opened'
  29. if serreset() then say 'serial device reset'
  30. say serid()
  31. if ~sersetparms( 9600, 8, 'N', 1 ) then say 'Parms not set'
  32. if ~serclear() then say 'buffer not clear'
  33. if serflush( w ) then say 'write queue flushed'
  34. if serflush( r ) then say 'read queue flushed'
  35. block = allocmem( 20 ) 
  36. addr = c2d( block )
  37. say 'memory block address =' addr
  38. query = SerQuery()
  39. parse var query err rl stat
  40. if ~err then say 'query status valid'
  41. say 'number of characters in received buffer:' rl
  42. say 'status word in ASCII decimal:' stat
  43. say 'waiting for 5 characters from the remote'
  44. text = SerRead( addr, 5 )
  45. say 'received:' text
  46. if ~freemem( block, 20 ) then say 'memory block not freed'
  47. text = 'send stuff out port again'
  48. say 'calling SerWrite'
  49. if ~serwrite( text, length( text ) ) then say 'nothing written'
  50. say 'back from SerWrite'
  51. error:
  52. if serclose() then say 'serial device closed' 
  53. if remlib( 'rexxserdev.library' ) then say 'removed rexxserdev.library'
  54.