beautypg.com

4 iic object method: sendbyte(byte), 5 iic object method: send(string) – Rainbow Electronics GM862-GPS User Manual

Page 48

background image





Easy Script

in Python

80000ST10020a Rev.8 - 01/10/08

Reproduction forbidden without Telit Communications S.p.A. written authorization - All Rights Reserved

page 48 of 100


ret = myIIC1.readwrite('\x08', 14) # Random read
print ' RANDOM READ FROM ADDR = 0x08, 14 bytes: %s' % ret
#MOD.sleep(5)

print ' Writing DATA= "hello!" from ADDR = 0x00'
myIIC1.readwrite('\x00'+ 'hello!', 0)
#MOD.sleep(5)

print ' SETTING CURRENT ADDRESS = 0x00'
if myIIC1.readwrite('\x00',0) == -1:
print 'Error acknowledged'
#MOD.sleep(5)

ret = myIIC1.readwrite('', 22) # Current address read
print ' CURRENT ADDR READ = 0x00, 22 bytes: %s' % ret
MOD.sleep(5)

ret = myIIC1.readwrite('\x00', 254) # Current address read
print ' read 254 bytes with readwrite: %s' % ret

2.8.4 IIC object method: sendbyte(byte)

Sends a byte to the IIC bus previously created. Input parameter byte is a Python byte which is the byte
to be sent to the IIC bus. The start and stop condition on the bus are added by the function.
Return value is a Python integer which is -1 if an error occurred otherwise is 1 the byte has been
acknowledged by the slave.

Example:

Supposing to set:

bus1 = IIC.new(3,4)
bus2 = IIC.new(5,6)
a = bus1.init()

then:

a = bus1.sendbyte(123)

sends byte 123 to the IIC bus , assigning return result value to a.

2.8.5 IIC object method: send(string)

Sends a string to the IIC bus previously created. Input parameter string is a Python string which is the
string to send to the IIC bus.