コード例 #1
0
ファイル: uds.py プロジェクト: kekelele/python-udsoncan
 def specific_send(self, payload):
     data = [i for i in bytes(payload)]
     msg = J2534.ptTxMsg(ProtocolID.ISO15765, 32)
     msg.setIDandData(SEND_ID, data)
     ret = J2534.ptWtiteMsgs(self.channel, msg, 1, 100)
     if ret == 0:
         msg.show()
コード例 #2
0
ファイル: uds.py プロジェクト: kekelele/python-udsoncan
    def open(self):
        ret, self.deviceID = J2534.ptOpen()
        ret, self.channel = J2534.ptConnect(self.deviceID, ProtocolID.ISO15765,
                                            0, BaudRate.B500K)
        if ret == 0:
            self.dev_status = True
        maskMsg = J2534.ptMskMsg(16)
        maskMsg.setID(0xffffffff)

        patternMsg = J2534.ptPatternMsg(16)
        patternMsg.setID(SEND_ID)

        flowcontrolMsg = J2534.ptPatternMsg(16)
        flowcontrolMsg.setID(RECV_ID)

        ret, fiterid = J2534.ptStartMsgFilter(self.channel,
                                              FilterType.FLOW_CONTROL_FILTER,
                                              maskMsg, patternMsg,
                                              flowcontrolMsg)
コード例 #3
0
ファイル: uds.py プロジェクト: kekelele/python-udsoncan
    def specific_wait_frame(self, timeout=2):
        msg = J2534.ptRxMsg()
        maskMsg = J2534.ptMskMsg(0)
        maskMsg.setID(0xffffffff)
        patternMsg = J2534.ptPatternMsg(0)
        patternMsg.setID(RECV_ID)

        flowcontrolMsg = J2534.ptPatternMsg(0)
        flowcontrolMsg.setID(SEND_ID)

        ret, fiterid = J2534.ptStartMsgFilter(self.channel,
                                              FilterType.FLOW_CONTROL_FILTER,
                                              maskMsg, patternMsg,
                                              flowcontrolMsg)

        ret = J2534.ptReadMsgs(self.channel, msg, 1, 100)
        #if ret == 0:
        #    msg.show()
        ret = J2534.ptReadMsgs(self.channel, msg, 1, 100)
        if ret == 0:
            msg.show()
            return bytes(msg.Data[4:msg.DataSize])
        return None
コード例 #4
0
#coding:utf-8
import J2534
from J2534.Define import *
import sys
J2534.SetErrorLog(True)
devices = J2534.getDevices()
try:
    index = int(sys.argv[1], base=10)
except:
    index = 0
J2534.setDevice(index)

ret, deviceID = J2534.ptOpen()

# connect one channel of the device
# set the baudrate to 500K
ret, channelID = J2534.ptConnect(deviceID, ProtocolID.CAN, 0, BaudRate.B500K)

print(channelID)
ret = J2534.ptDisconnect(channelID)
ret = J2534.ptClose(deviceID)
コード例 #5
0
#coding:utf-8
import J2534
from J2534.Define import *
import sys

J2534.SetErrorLog(False)
import time

BRODCAST_ID = 0x7df
SEND_ID = 0x7e0
RECV_ID = 0x7e8


try:
    index = int(sys.argv[1], base=10)
except:
    index = 0
J2534.setDevice(index)

ret, id1 = J2534.ptOpen()
ret, ch1 = J2534.ptConnect(id1, ProtocolID.ISO15765, 0, BaudRate.B500K)

msg = J2534.ptRxMsg()


maskMsg = J2534.ptMskMsg(0)
maskMsg.setID(0xffffffff)

patternMsg = J2534.ptPatternMsg(0)
patternMsg.setID(SEND_ID)
コード例 #6
0
#coding:utf-8
import J2534
J2534.MethodErrorLog = True
devices = J2534.getDevices()
for id in devices:
    print( id , devices[id])
コード例 #7
0
#coding:utf-8
import J2534
import sys

J2534.SetErrorLog(True)
devices = J2534.getDevices()

#
try:
    index = int(sys.argv[1], base=10)
except:
    index = 0

# select index of j2534 device
# PS:
# 0 {'Name': 'Mongoose ISO', 'FunctionLibrary': 'C:\\WINDOWS\\SysWOW64\\MONGI432.DLL'}
# 1 {'Name': 'ES581.4', 'FunctionLibrary': 'D:\\Program Files (x86)\\Common Files\\ETAS\\J2534 Interface\\ETAS32.dll'}
# 2 {'Name': 'J2534 for Kvaser Hardware', 'FunctionLibrary': 'd:\\Program Files\\Kvaser\\Drivers\\32\\kvJ2534.dll'}
# index = 0  select Mongoose ISO
J2534.setDevice(index)

# open J2534 device
ret, deviceID = J2534.ptOpen()

# read the
ret, FirmwareVersion, DllVersion, ApiVersion = J2534.ptReadVersion(deviceID)
print("DLL :", devices[index])
print("deviceID :", deviceID)
print("FirmwareVersion : %s" % FirmwareVersion)
print("DllVersion : %s" % DllVersion)
print("ApiVersion : %s" % ApiVersion)
コード例 #8
0
#coding:utf-8
import J2534
from J2534.Define import *
import sys

J2534.SetErrorLog(True)
import time

try:
    index = int(sys.argv[1], base=10)
except:
    index = 0
J2534.setDevice(index)

J2534.setDevice(key=index)
ret, id1 = J2534.ptOpen()
ret, ch1 = J2534.ptConnect(id1, ProtocolID.ISO15765, 0, 500000)

msg = J2534.ptTxMsg(ProtocolID.ISO15765, 32)

data = [2, 10, 3, 0, 0, 0, 0, 0, 0]
#data = data + [0]*padding(len(data))
msg.setIDandData(0x241, data)

maskMsg = J2534.ptMskMsg(16)
maskMsg.setID(0xffffffff)

patternMsg = J2534.ptPatternMsg(16)
patternMsg.setID(0x641)

flowcontrolMsg = J2534.ptPatternMsg(16)
コード例 #9
0
#coding:utf-8
import J2534
from J2534.Define import *
import sys
J2534.SetErrorLog(True)

devices = J2534.getDevices()
try:
    index = int(sys.argv[1], base=10)
except:
    index = 0
J2534.setDevice(index)

ret, deviceID = J2534.ptOpen()

ret, channelID = J2534.ptConnect(deviceID, ProtocolID.CAN, 0, BaudRate.B500K)

msg = J2534.ptTxMsg(ProtocolID.CAN, 0)
msg.setIDandData(0x123, [0, 1, 2, 3, 4, 5, 6, 7])

J2534.ptWtiteMsgs(channelID, msg, 1, 100)

ret = J2534.ptDisconnect(channelID)
ret = J2534.ptClose(deviceID)
コード例 #10
0
ファイル: uds.py プロジェクト: kekelele/python-udsoncan
 def close(self):
     ret = J2534.ptDisconnect(self.channel)
     ret = J2534.ptClose(self.deviceID)
コード例 #11
0
ファイル: uds.py プロジェクト: kekelele/python-udsoncan
import udsoncan
from udsoncan.connections import BaseConnection
from udsoncan.client import Client
from udsoncan.exceptions import *
from udsoncan.services import *
from abc import abstractmethod
BRODCAST_ID = 0x7df
SEND_ID = 0x7e0
RECV_ID = 0x7e8

import J2534
from J2534.Define import *
import sys
J2534.SetErrorLog(False)

try:
    index = int(sys.argv[1], base=10)
except:
    index = 0
J2534.setDevice(index)


class J2534Connect(BaseConnection):
    def __init__(self, name=None):
        self.dev_status = False
        return super().__init__(name=name)

    def open(self):
        ret, self.deviceID = J2534.ptOpen()
        ret, self.channel = J2534.ptConnect(self.deviceID, ProtocolID.ISO15765,
                                            0, BaudRate.B500K)
コード例 #12
0
ファイル: 09_Ioctl.py プロジェクト: navitel/python_j2534
#coding:utf-8
import J2534
from J2534.Define import *
import sys

J2534.SetErrorLog(True)

BRODCAST_ID = 0x7df
SEND_ID = 0x7e0
RECV_ID = 0x7e8

try:
    index = int(sys.argv[1], base=10)
except:
    index = 0
J2534.setDevice(index)

ret, id1 = J2534.ptOpen()
ret, ch1 = J2534.ptConnect(id1, ProtocolID.ISO15765, 0, BaudRate.B500K)

ret, vbat = J2534.ReadVbat(ch1)
ret = J2534.ClearTxBuf(ch1)
ret = J2534.ClearRxBuf(ch1)

ret = J2534.ptDisconnect(ch1)
ret = J2534.ptClose(id1)