beautypg.com

6 iic object method: dev_read(addr, len), 7 iic object method: dev_write(addr, string) – Rainbow Electronics GM862-GPS User Manual

Page 49

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 49 of 100

Return value is a Python integer which is -1 if an error occurred otherwise is 1 if all bytes of the string
have been acknowledged by the slave.

Example:

a = bus1.send('test')

sends string 'test' to the IIC bus , assigning return result value to a.

2.8.6 IIC object method: dev_read(addr, len)

Receives a string of len bytes from IIC bus device at address addr.
Return value is a Python string which is containing data received.

Example:

a = bus1.dev_read(114,10)

receives a string of 10 bytes from IIC bus device at address 114, assigning it to a.

2.8.7 IIC object method: dev_write(addr, string)

Sends a string to the IIC bus device at address addr.
Return value is a Python string which is 1 if data is acknowledged correctly, -1 otherwise.

Example:

a = bus1.dev_write(114,'123456789')

sends the string '123456789' to the IIC bus device at address 114, assigning the result to a.

2.8.8 IIC object method: dev_gen_read(addr, start, len)

Receives a string of len bytes from IIC bus device whose address is addr, starting from address start.
Return value is a Python string which is containing data received.

Example:

a = bus1.dev_gen_read(114,122, 10)
receives a string of 10 bytes from IIC bus device at address 114, starting from address 122 assigning
it to a.