Fixed SPI error
This commit is contained in:
parent
0f103cb34d
commit
4f564ca759
2 changed files with 11 additions and 9 deletions
|
@ -33,12 +33,12 @@ class IRSensor(object):
|
||||||
raise IndexError("Invalid sensor specified!")
|
raise IndexError("Invalid sensor specified!")
|
||||||
|
|
||||||
if sensor == 1:
|
if sensor == 1:
|
||||||
Spi.write(Register.IR_1_LED, on)
|
Spi.write(Register.IR_1_LED, 1, on)
|
||||||
elif sensor == 2:
|
elif sensor == 2:
|
||||||
Spi.write(Register.IR_2_LED, on)
|
Spi.write(Register.IR_2_LED, 1, on)
|
||||||
elif sensor == 3:
|
elif sensor == 3:
|
||||||
Spi.write(Register.IR_3_LED, on)
|
Spi.write(Register.IR_3_LED, 1, on)
|
||||||
elif sensor == 4:
|
elif sensor == 4:
|
||||||
Spi.write(Register.IR_4_LED, on)
|
Spi.write(Register.IR_4_LED, 1, on)
|
||||||
elif sensor == 5:
|
elif sensor == 5:
|
||||||
Spi.write(Register.IR_5_LED, on)
|
Spi.write(Register.IR_5_LED, 1, on)
|
|
@ -2,8 +2,9 @@ import spidev
|
||||||
from threading import Thread, Lock
|
from threading import Thread, Lock
|
||||||
from enum import IntEnum
|
from enum import IntEnum
|
||||||
import time
|
import time
|
||||||
|
import sys
|
||||||
|
|
||||||
from compLib.LogstashLogging import logstash_logger
|
from compLib.LogstashLogging import Logging
|
||||||
|
|
||||||
SPI_BUS = 1
|
SPI_BUS = 1
|
||||||
SPI_DEVICE = 2
|
SPI_DEVICE = 2
|
||||||
|
@ -100,7 +101,7 @@ class Spi(object):
|
||||||
rx_buffer = spi.xfer([0] * 32)
|
rx_buffer = spi.xfer([0] * 32)
|
||||||
|
|
||||||
if rx_buffer[1] != write_reg:
|
if rx_buffer[1] != write_reg:
|
||||||
logstash_logger.error(f"SPI error during read/write of register {write_reg}!")
|
Logging.get_logger().error(f"SPI error during read/write of register {write_reg}!")
|
||||||
|
|
||||||
return rx_buffer
|
return rx_buffer
|
||||||
|
|
||||||
|
@ -159,8 +160,9 @@ class Spi(object):
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def health_check():
|
def health_check():
|
||||||
if Spi.read(Register.IDENTIFICATION_MODEL_ID, 1) != 3:
|
if Spi.read(Register.IDENTIFICATION_MODEL_ID, 1) != 3:
|
||||||
logstash_logger.error(f"Unable to read Version! Make sure the mainboard is connected!")
|
Logging.get_logger().error(f"Unable to read Version! Make sure the mainboard is connected!")
|
||||||
quit()
|
print("Unable to read Version! Make sure the mainboard is connected!")
|
||||||
|
sys.exit()
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def health_check_loop():
|
def health_check_loop():
|
||||||
|
|
Reference in a new issue