Beispiel #1
0
 def test_init(self):
     frame = can.Frame(0x55, 6, [1, 2, 3, 4, 5, 6],
                       can.FrameType.ErrorFrame, True)
     self.assertEqual(frame.id, 0x55)
     self.assertEqual(frame.data, [1, 2, 3, 4, 5, 6, None, None])
     self.assertEqual(frame.frame_type, can.FrameType.ErrorFrame)
     self.assertEqual(frame.is_extended_id, True)
Beispiel #2
0
from cancom import can
from cancom.hw import cantact
from cancom.utils.queue import CanQueue
import time
import sys

dev = cantact.CantactDev(sys.argv[1])
dev.set_bitrate(125000)
cq = CanQueue(dev)

cq.start()

print cq.recv()

req = can.Frame(0x6A5)
req.dlc = 8
req.data = [0x10, 0xFF, 0xFF]

cq.send(req)

print cq.recv(filter=0x625, timeout=10)

cq.stop()

#dev.stop()
#dev.ser.write('S0\r')
#dev.start()

#while True:
#    frame = can.Frame(0x10)
#    frame.dlc=3
Beispiel #3
0
from cancom import can
from cancom.hw import peak
from cancom.hw import socketcan

#dev = peak.PcanDev()
dev = socketcan.SocketCanDev("vcan0")

dev.start()

frame = can.Frame(0)
frame.dlc = 8

while True:
    dev.send(frame)
Beispiel #4
0
from cancom import can
from cancom.hw import peak
from cancom.hw import socketcan

#dev = peak.PcanDev()
dev = socketcan.SocketCanDev("vcan0")

dev.start()

frame = can.Frame(0x7DF)
frame.dlc = 8

# frame data
# byte 0: number of additional bytes (1)
# byte 1: mode. mode 04 clears MIL
# other bytes not used, set to 0x55
frame.data = [1, 4, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55]

dev.send(frame)
Beispiel #5
0
import sys

from cancom.proto.uds import UdsInterface
from cancom.hw.socketcan import SocketCanDev
from cancom import can

d = SocketCanDev('vcan0')
d.start()

while True:
    frame = d.recv()
    if frame.id == 0x705:
        resp = can.Frame(0x725)
        resp.dlc = 8
        resp.data = [0x02, 0x41]
        d.send(resp)



Beispiel #6
0
 def setUp(self):
     self.frame = can.Frame(0)
Beispiel #7
0
from cancom.proto.isotp import IsoTpProtocol, IsoTpMessage
from cancom import can

p = IsoTpProtocol()


f = can.Frame(0x100)
f.data = [3,1,2,3]
f.dlc = 4

#print(p.parse_frame(f))

f.data = [0x10, 20, 1, 2, 3, 4, 5, 6]
f.dlc = 8
print(p.parse_frame(f))
f.data = [0x21, 7, 8, 9, 10, 11, 12, 13]
#print(p.parse_frame(f))
f.data = [0x22, 7, 8, 9, 10, 11, 12, 13]
#print(p.parse_frame(f))

m = IsoTpMessage(0x100)
m.data = range(1,0xFF)
m.length = 0x1FF
for fr in p.generate_frames(m):
    print fr
Beispiel #8
0
from cancom import can
from cancom.hw import cantact
import time

# default value (Ubuntu) for first cantact device
dev = cantact.CantactDev("/dev/ttyACM0")

# comfort CAN
dev.set_bitrate(100000)

# start cantact
dev.start()

DRIVER_UP = can.Frame(0x182, 3, [0x20, 0x00, 0x00])

for x in range(0, 10000):
    dev.send(DRIVER_UP)
    time.sleep(.25)