Fix CAN keyword arg.

* sampling_point was renamed to sample_point in upstream.
This commit is contained in:
iabdalkader 2022-01-15 23:29:40 +02:00
parent 2ae2465d6a
commit b565eca585
11 changed files with 25 additions and 25 deletions

View File

@ -9,7 +9,7 @@ from pyb import CAN
# NOTE: Set to False on receiving node.
TRANSMITTER = True
can = CAN(2, CAN.NORMAL, baudrate=125_000, sampling_point=75)
can = CAN(2, CAN.NORMAL, baudrate=125_000, sample_point=75)
# NOTE: uncomment to set bit timing manually, for example:
#can.init(CAN.NORMAL, prescaler=32, sjw=1, bs1=8, bs2=3)
can.restart()

View File

@ -17,12 +17,12 @@ import image, network, omv, rpc, sensor, struct, time
#
# * message_id - CAN message to use for data transport on the can bus (11-bit).
# * bit_rate - CAN bit rate.
# * sampling_point - Tseg1/Tseg2 ratio. Typically 75%. (50.0, 62.5, 75.0, 87.5, etc.)
# * sample_point - Tseg1/Tseg2 ratio. Typically 75%. (50.0, 62.5, 75.0, 87.5, etc.)
#
# NOTE: Master and slave message ids and can bit rates must match. Connect master can high to slave
# can high and master can low to slave can lo. The can bus must be terminated with 120 ohms.
#
# interface = rpc.rpc_can_master(message_id=0x7FF, bit_rate=1000000, sampling_point=75.0)
# interface = rpc.rpc_can_master(message_id=0x7FF, bit_rate=1000000, sample_point=75.0)
# Uncomment the below line to setup your OpenMV Cam for controlling over I2C.
#

View File

@ -22,12 +22,12 @@ sensor.skip_frames(time = 2000)
#
# * message_id - CAN message to use for data transport on the can bus (11-bit).
# * bit_rate - CAN bit rate.
# * sampling_point - Tseg1/Tseg2 ratio. Typically 75%. (50.0, 62.5, 75.0, 87.5, etc.)
# * sample_point - Tseg1/Tseg2 ratio. Typically 75%. (50.0, 62.5, 75.0, 87.5, etc.)
#
# NOTE: Master and slave message ids and can bit rates must match. Connect master can high to slave
# can high and master can low to slave can lo. The can bus must be terminated with 120 ohms.
#
# interface = rpc.rpc_can_slave(message_id=0x7FF, bit_rate=1000000, sampling_point=75.0)
# interface = rpc.rpc_can_slave(message_id=0x7FF, bit_rate=1000000, sample_point=75.0)
# Uncomment the below line to setup your OpenMV Cam for control over I2C.
#

View File

@ -19,12 +19,12 @@ import json, rpc, struct
#
# * message_id - CAN message to use for data transport on the can bus (11-bit).
# * bit_rate - CAN bit rate.
# * sampling_point - Tseg1/Tseg2 ratio. Typically 75%. (50.0, 62.5, 75, 87.5, etc.)
# * sample_point - Tseg1/Tseg2 ratio. Typically 75%. (50.0, 62.5, 75, 87.5, etc.)
#
# NOTE: Master and slave message ids and can bit rates must match. Connect master can high to slave
# can high and master can low to slave can lo. The can bus must be terminated with 120 ohms.
#
# interface = rpc.rpc_can_master(message_id=0x7FF, bit_rate=250000, sampling_point=75)
# interface = rpc.rpc_can_master(message_id=0x7FF, bit_rate=250000, sample_point=75)
# Uncomment the below line to setup your OpenMV Cam for controlling over I2C.
#

View File

@ -24,12 +24,12 @@ sensor.skip_frames(time = 2000)
#
# * message_id - CAN message to use for data transport on the can bus (11-bit).
# * bit_rate - CAN bit rate.
# * sampling_point - Tseg1/Tseg2 ratio. Typically 75%. (50.0, 62.5, 75, 87.5, etc.)
# * sample_point - Tseg1/Tseg2 ratio. Typically 75%. (50.0, 62.5, 75, 87.5, etc.)
#
# NOTE: Master and slave message ids and can bit rates must match. Connect master can high to slave
# can high and master can low to slave can lo. The can bus must be terminated with 120 ohms.
#
# interface = rpc.rpc_can_slave(message_id=0x7FF, bit_rate=250000, sampling_point=75)
# interface = rpc.rpc_can_slave(message_id=0x7FF, bit_rate=250000, sample_point=75)
# Uncomment the below line to setup your OpenMV Cam for control over I2C.
#

View File

@ -9,7 +9,7 @@ from pyb import CAN
# NOTE: Set to False on receiving node.
TRANSMITTER = True
can = CAN(2, CAN.NORMAL, baudrate=125_000, sampling_point=75)
can = CAN(2, CAN.NORMAL, baudrate=125_000, sample_point=75)
# NOTE: uncomment to set bit timing manually, for example:
#can.init(CAN.NORMAL, prescaler=32, sjw=1, bs1=8, bs2=3)
can.restart()

View File

@ -17,12 +17,12 @@ import image, network, omv, rpc, sensor, struct, time
#
# * message_id - CAN message to use for data transport on the can bus (11-bit).
# * bit_rate - CAN bit rate.
# * sampling_point - Tseg1/Tseg2 ratio. Typically 75%. (50.0, 62.5, 75.0, 87.5, etc.)
# * sample_point - Tseg1/Tseg2 ratio. Typically 75%. (50.0, 62.5, 75.0, 87.5, etc.)
#
# NOTE: Master and slave message ids and can bit rates must match. Connect master can high to slave
# can high and master can low to slave can lo. The can bus must be terminated with 120 ohms.
#
# interface = rpc.rpc_can_master(message_id=0x7FF, bit_rate=1000000, sampling_point=75.0)
# interface = rpc.rpc_can_master(message_id=0x7FF, bit_rate=1000000, sample_point=75.0)
# Uncomment the below line to setup your OpenMV Cam for controlling over I2C.
#

View File

@ -22,12 +22,12 @@ sensor.skip_frames(time = 2000)
#
# * message_id - CAN message to use for data transport on the can bus (11-bit).
# * bit_rate - CAN bit rate.
# * sampling_point - Tseg1/Tseg2 ratio. Typically 75%. (50.0, 62.5, 75.0, 87.5, etc.)
# * sample_point - Tseg1/Tseg2 ratio. Typically 75%. (50.0, 62.5, 75.0, 87.5, etc.)
#
# NOTE: Master and slave message ids and can bit rates must match. Connect master can high to slave
# can high and master can low to slave can lo. The can bus must be terminated with 120 ohms.
#
# interface = rpc.rpc_can_slave(message_id=0x7FF, bit_rate=1000000, sampling_point=75.0)
# interface = rpc.rpc_can_slave(message_id=0x7FF, bit_rate=1000000, sample_point=75.0)
# Uncomment the below line to setup your OpenMV Cam for control over I2C.
#

View File

@ -19,12 +19,12 @@ import json, rpc, struct
#
# * message_id - CAN message to use for data transport on the can bus (11-bit).
# * bit_rate - CAN bit rate.
# * sampling_point - Tseg1/Tseg2 ratio. Typically 75%. (50.0, 62.5, 75, 87.5, etc.)
# * sample_point - Tseg1/Tseg2 ratio. Typically 75%. (50.0, 62.5, 75, 87.5, etc.)
#
# NOTE: Master and slave message ids and can bit rates must match. Connect master can high to slave
# can high and master can low to slave can lo. The can bus must be terminated with 120 ohms.
#
# interface = rpc.rpc_can_master(message_id=0x7FF, bit_rate=250000, sampling_point=75)
# interface = rpc.rpc_can_master(message_id=0x7FF, bit_rate=250000, sample_point=75)
# Uncomment the below line to setup your OpenMV Cam for controlling over I2C.
#

View File

@ -24,12 +24,12 @@ sensor.skip_frames(time = 2000)
#
# * message_id - CAN message to use for data transport on the can bus (11-bit).
# * bit_rate - CAN bit rate.
# * sampling_point - Tseg1/Tseg2 ratio. Typically 75%. (50.0, 62.5, 75, 87.5, etc.)
# * sample_point - Tseg1/Tseg2 ratio. Typically 75%. (50.0, 62.5, 75, 87.5, etc.)
#
# NOTE: Master and slave message ids and can bit rates must match. Connect master can high to slave
# can high and master can low to slave can lo. The can bus must be terminated with 120 ohms.
#
# interface = rpc.rpc_can_slave(message_id=0x7FF, bit_rate=250000, sampling_point=75)
# interface = rpc.rpc_can_slave(message_id=0x7FF, bit_rate=250000, sample_point=75)
# Uncomment the below line to setup your OpenMV Cam for control over I2C.
#

View File

@ -282,20 +282,20 @@ class rpc_slave(rpc):
self.__schedule_cb = None
if self.__loop_cb is not None: self.__loop_cb()
def __get_can_settings(bit_rate, sampling_point):
def __get_can_settings(bit_rate, sample_point):
clk = 48000000 if omv.board_type() == "H7" else pyb.freq()[2]
for prescaler in range(8):
for bs1 in range(16):
for bs2 in range(8):
if bit_rate == ((clk >> prescaler) // (1 + bs1 + bs2)) and (sampling_point * 10) == (((1 + bs1) * 1000) // (1 + bs1 + bs2)):
if bit_rate == ((clk >> prescaler) // (1 + bs1 + bs2)) and (sample_point * 10) == (((1 + bs1) * 1000) // (1 + bs1 + bs2)):
return (1 << prescaler, bs1, bs2)
raise ValueError("Invalid bit_rate and/or sampling_point!")
raise ValueError("Invalid bit_rate and/or sample_point!")
class rpc_can_master(rpc_master):
def __init__(self, message_id=0x7FF, bit_rate=250000, sampling_point=75, can_bus=2):
def __init__(self, message_id=0x7FF, bit_rate=250000, sample_point=75, can_bus=2):
self.__message_id = message_id
can_prescaler, can_bs1, can_bs2 = __get_can_settings(bit_rate, sampling_point)
can_prescaler, can_bs1, can_bs2 = __get_can_settings(bit_rate, sample_point)
self.__can = pyb.CAN(can_bus, pyb.CAN.NORMAL, prescaler=can_prescaler, bs1=can_bs1, bs2=can_bs2, auto_restart=True)
self.__can.setfilter(0, pyb.CAN.DUAL if omv.board_type() == "H7" else pyb.CAN.LIST32, 0, [message_id, message_id])
rpc_master.__init__(self)
@ -328,9 +328,9 @@ class rpc_can_master(rpc_master):
class rpc_can_slave(rpc_slave):
def __init__(self, message_id=0x7FF, bit_rate=250000, sampling_point=75, can_bus=2):
def __init__(self, message_id=0x7FF, bit_rate=250000, sample_point=75, can_bus=2):
self.__message_id = message_id
can_prescaler, can_bs1, can_bs2 = __get_can_settings(bit_rate, sampling_point)
can_prescaler, can_bs1, can_bs2 = __get_can_settings(bit_rate, sample_point)
self.__can = pyb.CAN(can_bus, pyb.CAN.NORMAL, prescaler=can_prescaler, bs1=can_bs1, bs2=can_bs2, auto_restart=True)
self.__can.setfilter(0, pyb.CAN.DUAL if omv.board_type() == "H7" else pyb.CAN.LIST32, 0, [message_id, message_id])
rpc_slave.__init__(self)