Skip to content
Snippets Groups Projects
Commit e6c3cb63 authored by Gijs Schoonderbeek's avatar Gijs Schoonderbeek
Browse files

Added I2C_serial_iss.py and modified apspu_lib.py to be used for the...

Added I2C_serial_iss.py and modified apspu_lib.py to be used for the production test setup. We might have to update the apspu_lib.py again for the final test testup.
parent 5a623aee
No related branches found
No related tags found
No related merge requests found
"""
I2C Class
"""
from usb_iss import UsbIss, defs
from time import *
import sys
sys.path.insert(0, 'c:\python34\lib\site-packages')
DEBUG = False
port = 'COM3'
iss = UsbIss()
try:
iss.open(port)
iss.setup_i2c(400, True, None, None)
except:
print("already in use")
class I2C:
def __init__(self, address=0x40):
self.I2C_Address = address
self.BUS_NR = 1 # not used for Laptop but to enable Pi multiple busses.
def read_bytes(self, register, bytes_to_read=2):
ret_value = ''
read_values = iss.i2c.read(self.I2C_Address, register, bytes_to_read)
for x in read_values:
ret_value += hex(x)[2:]
ret_ack = True
ret_value = ret_value #.decode("utf-8")
return ret_ack, ret_value
def read_last_reg(self, bytes_to_read):
ret_value = []
for cnt in range(bytes_to_read):
ret_value += hex(iss.i2c.read_single(self.I2C_Address))[2:]
ret_value = ret_value
ret_ack = 1
return ret_ack, ret_value
def write_bytes(self, register, data):
if len([data]) < 2:
data = [data]
iss.i2c.write(self.I2C_Address, register, data)
ret_ack = 1
return ret_ack
def write_pointer(self, register):
iss.i2c.write_single(self.I2C_Address, register)
return ret_ack
if __name__ == "__main__":
I2C_Device = I2C(0x40)
I2C_Device.write_bytes(0x00, 0x00)
ret_ack, ret_value = I2C_Device.read_bytes(0x8C, 2)
print(ret_value)
......@@ -24,8 +24,10 @@ import math
from APSPU_I2C import *
if os.name == "posix":
if 0: #os.name == "posix":
from I2C_serial_pi3 import *
elif 1:
from I2C_serial_iss import *
else:
from I2C_serial import *
......@@ -515,7 +517,11 @@ class FanmonitorClass:
if DEBUG:
stri = "Device {0} at address 0x{1:X} is found ".format("MAX6620", MAX6620)
print(stri)
try:
self.set_active()
except:
self.status = False
else:
self.status = True
def set_active(self):
......@@ -595,20 +601,20 @@ def main():
# Function to test the class, read all info and dump on the screen
#
apspu = ApspuClass()
apspu.apspu_on_off(False)
sleep(5)
apspu.set_pols()
apspu.apspu_on_off(True)
sleep(10)
# apspu.apspu_on_off(False)
# sleep(5)
# apspu.set_pols()
# apspu.apspu_on_off(True)
# sleep(10)
# apspu.read_all()
# apspu.print_status()
# apspu.check_apspu()
# apspu.apspu_on_off(False)
# sleep(10)
apspu.read_all()
apspu.print_status()
apspu.check_apspu()
apspu.apspu_on_off(False)
sleep(10)
apspu.read_all()
apspu.print_status()
apspu.apspu_on_off(True)
# apspu.apspu_on_off(True)
# apspu.eeprom.wr_rd_eeprom(value="APSPU-2", address=0)
if __name__ == "__main__":
main()
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment