🎯 Biblioteca Python-can em Python

Em poucas palavras

  • A rede CAN permite apenas a comunicação de dados de 8 bytes. Portanto, o tamanho máximo da variável de dados da mensagem deve ser de 8 bytes.

📝 Notas e Desenvolvimento


🔗 Conexões e Contexto


📚 Referências e Fontes

Citações Diretas

📂 Outros Conteúdos Preservados

Exemplo de Uso Simples

 
### import the library
 
import can
 
### create a bus instance using 'with' statement,
 
 
 
### this will cause bus.shutdown() to be called on the block exit; # many other interfaces are supported as well (see documentation)
 
with can.Bus(interface='socketcan',
	channel='vcan0',
	receive_own_messages=True) as bus:
	
	# send a message
	message = can.Message(arbitration_id=123, is_extended_id=True,
	data=[0x11, 0x22, 0x33])
	bus.send(message, timeout=0.2)
	
	# iterate over received messages
	for msg in bus:
		print(f"{msg.arbitration_id:X}: {msg.data}")
	
	# or use an asynchronous notifier
	notifier = can.Notifier(bus, [can.Logger("recorded.log"), can.Printer()])