home *** CD-ROM | disk | FTP | other *** search
/ hobbes.nmsu.edu / 2008-06-02_hobbes.nmsu.edu.zip / new / rxowire.zip / rxOWire.cmd < prev    next >
OS/2 REXX Batch file  |  2008-05-27  |  1KB  |  50 lines

  1. /* RXOWIRE.CMD */
  2. /* Written by Lone Peak Automation */
  3.  
  4. /* Load RXEXIF.DLL */
  5. CALL RXFuncAdd 'rxOWireLoadFuncs', 'RXOWIRE', 'rxOWireLoadFuncs'
  6. CALL rxOWireLoadFuncs
  7.  
  8. SAY ''
  9. SAY '--- Sample REXX Program for accessing 1-Wire data. ---'
  10. SAY '    The RS-232 based DS9097U interface is required'
  11. SAY '    to read temperature from a DS1820 sensor.'
  12. SAY '    See www.maxim-ic.com for details on 1-Wire devices.'
  13. SAY ''
  14.  
  15. rc = rxOWireDllVersion()
  16. SAY "rxOWire.DLL version is: " || rc
  17.  
  18. rc = rxOWireOpen(0)  /* 0=COM1, 1=COM2... */
  19. SAY "Port open (1=ok, 10=invalid com port, 11=no DS9097U Detected) rc = : " || rc
  20.  
  21. IF rc = 1 THEN
  22.   DO
  23.    
  24.    SAY 'rxOWire find all:'
  25.    rc = rxOWireFindAll()
  26.    SAY 'Devices found: ' || rc
  27.  
  28.    SAY 'Time = ' || TIME('E')
  29.    rc = rxOWireGetTemp()  
  30.    SAY 'Elapsed time = ' || TIME('R')
  31.    SAY 'Get Temperature: ' || rc
  32.    SAY "Get Temp (ok = 10 byte hex string, 10=no DS1820 found)"
  33.  
  34.    IF LENGTH(rc) > 4 THEN
  35.      DO
  36.        RawTemp = X2D(SUBSTR(rc, 3, 2))
  37.        CurrTemp = FORMAT(RawTemp / 2, 3, 2)
  38.        SAY 'Temperature in degrees Celsius = ' || CurrTemp
  39.      END
  40.  
  41.    rc = rxOWireClose()
  42.    SAY "Port close (1=ok, 20=close err) rc = : " || rc
  43.   END
  44.  
  45. SAY 'rxOWire test complete.'
  46. CALL rxOWireDROPFuncs
  47. SAY 'rxOWire.DLL dropped.'
  48.  
  49. EXIT
  50.