while using isotp.CanStack & stack.process and setting stmin in funtion set_fc_opts doesn't have a consistent stmin time gap between messages of flow control. if 10 ms is set then there are instances of 0.008 or 0.006 which occurs during runtime with a complimentary stmin of 0.011 or 0.013 .
import isotp
import can
from can.interface import Bus
import time
while True:
isotp_params = {
'stmin': 255, # Will request the sender to wait 32ms between consecutive frame. 0-127ms or 100-900ns with values from 0xF1-0xF9
'blocksize' : 0, # Request the sender to send 8 consecutives frames before sending a new flow control message
'wftmax': 0, # Number of wait frame allowed before triggering an error
'tx_data_length': 8, # Link layer (CAN layer) works with 8 byte payload (CAN 2.0)
'tx_padding': 0, # Will pad all transmitted CAN messages with byte 0x00. None means no padding
'rx_flowcontrol_timeout': 1000, # Triggers a timeout if a flow control is awaited for more than 1000 milliseconds
'rx_consecutive_frame_timeout': 1000, # Triggers a timeout if a consecutive frame is awaited for more than 1000 milliseconds
'squash_stmin_requirement': False # When sending, respect the stmin requirement of the receiver. If set to True, go as fast as possible.
}
#lst = [40, 41, 42, 34, 48, 50, 63, 15, 66, 99, 12, 87, 59, 9, 78, 44]
lst = []
data = bytes(lst)
bus = Bus(bustype='socketcan', channel='can1', bitrate=500000, receive_own_messages=True)
rxid = 0x628
txid = 0x6A8
isExtId = False
s = isotp.socket()
tp_addr = isotp.Address(isExtId, rxid=rxid, txid=txid)
stack = isotp.CanStack(bus, address = tp_addr, params = isotp_params)
s.set_fc_opts(stmin=10, bs=0)
s.bind("can1", tp_addr)
stack.send(data)
while stack.transmitting():
stack.process()
time.sleep(stack.sleep_time())
time.sleep(3)
import isotp
import can
from can.interface import Bus
import time
isotp_params = {
'stmin': 255, # Will request the sender to wait 32ms between consecutive frame. 0-127ms or 100-900ns with values from 0xF1-0xF9
'blocksize' : 0, # Request the sender to send 8 consecutives frames before sending a new flow control message
'wftmax': 0, # Number of wait frame allowed before triggering an error
'll_data_length': 8, # Link layer (CAN layer) works with 8 byte payload (CAN 2.0)
'tx_padding': 0, # Will pad all transmitted CAN messages with byte 0x00. None means no padding
'rx_flowcontrol_timeout': 1000, # Triggers a timeout if a flow control is awaited for more than 1000 milliseconds
'rx_consecutive_frame_timeout': 1000, # Triggers a timeout if a consecutive frame is awaited for more than 1000 milliseconds
'squash_stmin_requirement': False # When sending, respect the stmin requirement of the receiver. If set to True, go as fast as possible.
}
rxid = 0x6A8
txid = 0x628
isExtId = False
bus = Bus(bustype='socketcan', channel='can0', bitrate=500000, receive_own_messages=True)
lst = [10, 21, 72, 33, 48, 50, 63, 15, 66, 99, 12, 87, 59, 9, 78, 44, 10, 21, 72, 33, 48, 50, 63, 15, 66, 99, 12, 87, 59, 9, 78, 44]
for x in range(190):
lst.append(x)
data = bytes(lst)
def can_isotp_tx(bus, isExtId, rxid, txid, data, receiver = False):
s = isotp.socket()
tp_addr = isotp.Address(isExtId, rxid=rxid, txid=txid)
s.bind("can0", tp_addr)
stack = isotp.CanStack(bus = bus, address = tp_addr, params = isotp_params)
s.send(data)
time.sleep(2)
while True:
can_isotp_tx(bus, isExtId, rxid, txid, data, receiver = False)