Difference between revisions of "Python/ltrx apis"

From Lantronix Wiki!
Jump to navigation Jump to search
Line 27: Line 27:
 
from ltrxlib import LtrxDsal
 
from ltrxlib import LtrxDsal
  
try:
 
    dsal = LtrxDsal()
 
  
    print 'Reading Digital Input 1...'
+
dsal = LtrxDsal()
    state = dsal.readDigitalInput(1)
 
    print 'state=' + str(state)
 
  
    print 'Reading Digital Input 2...'
+
print 'Reading Digital Input 1...'
    state = dsal.readDigitalInput(2)
+
state = dsal.readDigitalInput(1)
    print 'state=' + str(state)
+
print 'state=' + str(state)
  
    print 'Setting relay to true'
+
print 'Reading Digital Input 2...'
    result = dsal.setRelay(1, True)
+
state = dsal.readDigitalInput(2)
 +
print 'state=' + str(state)
  
    print 'Reading relay 1...'
+
print 'Setting relay to true'
    state = dsal.readRelay(1)
+
result = dsal.setRelay(1, True)
    print 'Relay is' + state
 
  
    print 'Setting relay to false...'
+
print 'Reading relay 1...'
    dsal.setRelay(1, False)
+
state = dsal.readRelay(1)
    print 'Reading Relay...'
+
print 'Relay is' + state
    state = dsal.readRelay(1,)
+
 
    print 'Relay is' + state
+
print 'Setting relay to false...'
 +
dsal.setRelay(1, False)
 +
print 'Reading Relay...'
 +
state = dsal.readRelay(1,)
 +
print 'Relay is' + state
 
    
 
    
    print 'Reading temperature...'
+
print 'Reading temperature...'
    temp = dsal.readInternalTemperature(1)
+
temp = dsal.readInternalTemperature(1)
 
  </nowiki>
 
  </nowiki>

Revision as of 18:57, 9 April 2015

Overview

Lantronix provides Python modules with APIs to access features of the PremierWave device more easily from your program.

Note that these APIs require firmware version 7.10 or later.

LtrxCellular

Send and receive SMS messages.

from ltrxlib import LtrxCellular


cell = LtrxCellular()
print 'calling sendSMS()...'
cell.sendSMS("1112223333", "Hello!", 0)  # 3rd argument: 0=ASCII 7 bits, 1=ASCII 8 bits, 2=unicode/utf-8

print 'calling receiveSMS'
msg = cell.receiveSMS()
print 'message: ' + msg
 

LtrxDsal

Access to the Digital input/outputs on the device.

from ltrxlib import LtrxDsal


dsal = LtrxDsal()

print 'Reading Digital Input 1...'
state = dsal.readDigitalInput(1)
print 'state=' + str(state)

print 'Reading Digital Input 2...'
state = dsal.readDigitalInput(2)
print 'state=' + str(state)

print 'Setting relay to true'
result = dsal.setRelay(1, True)

print 'Reading relay 1...'
state = dsal.readRelay(1)
print 'Relay is' + state

print 'Setting relay to false...'
dsal.setRelay(1, False)
print 'Reading Relay...'
state = dsal.readRelay(1,)
print 'Relay is' + state
  
print 'Reading temperature...'
temp = dsal.readInternalTemperature(1)