Release 260308

This commit is contained in:
Comma Device
2026-03-08 23:26:57 +08:00
commit 5c73e264e9
2665 changed files with 717560 additions and 0 deletions

2
panda/.dockerignore Normal file
View File

@@ -0,0 +1,2 @@
.git
.DS_Store

View File

@@ -0,0 +1,36 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
hooks:
- id: check-ast
- id: check-yaml
- id: check-merge-conflict
- id: check-symlinks
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.4.1
hooks:
- id: mypy
additional_dependencies: ['git+https://github.com/numpy/numpy-stubs', 'types-requests', 'types-atomicwrites',
'types-pycurl']
- repo: https://github.com/PyCQA/flake8
rev: 6.1.0
hooks:
- id: flake8
args:
- --select=F,E112,E113,E304,E501,E502,E701,E702,E703,E71,E72,E731,W191,W6
- --exclude=tests/gmbitbang/*
- --max-line-length=160
- --statistics
- repo: local
hooks:
- id: pylint
name: pylint
entry: pylint
language: system
types: [python]
args:
- -rn
- -sn
- -j0
- --disable=C,R,W0613,W0511,W0212,W0201,W0311,W0106,W0603,W0621,W0703,W0719,W1203,W1514,E1136
- --generated-members="usb1.*"

98
panda/Dockerfile Normal file
View File

@@ -0,0 +1,98 @@
FROM ubuntu:20.04
ENV PYTHONUNBUFFERED 1
ENV PYTHONPATH /tmp/openpilot:$PYTHONPATH
ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update && apt-get install -y --no-install-recommends \
autoconf \
automake \
bzip2 \
ca-certificates \
capnproto \
clang \
curl \
g++ \
gcc-arm-none-eabi libnewlib-arm-none-eabi \
git \
libarchive-dev \
libavformat-dev libavcodec-dev libavdevice-dev libavutil-dev libswscale-dev libavresample-dev libavfilter-dev \
libbz2-dev \
libcapnp-dev \
libcurl4-openssl-dev \
libffi-dev \
libtool \
libssl-dev \
libsqlite3-dev \
libusb-1.0-0 \
libzmq3-dev \
locales \
opencl-headers \
ocl-icd-opencl-dev \
make \
patch \
pkg-config \
python \
python-dev \
qt5-default \
unzip \
wget \
zlib1g-dev \
&& rm -rf /var/lib/apt/lists/* && \
cd /usr/lib/gcc/arm-none-eabi/9.2.1 && \
rm -rf arm/ && \
rm -rf thumb/nofp thumb/v6* thumb/v8* thumb/v7+fp thumb/v7-r+fp.sp
RUN sed -i -e 's/# en_US.UTF-8 UTF-8/en_US.UTF-8 UTF-8/' /etc/locale.gen && locale-gen
ENV LANG en_US.UTF-8
ENV LANGUAGE en_US:en
ENV LC_ALL en_US.UTF-8
RUN curl -L https://github.com/pyenv/pyenv-installer/raw/master/bin/pyenv-installer | bash
ENV PATH="/root/.pyenv/bin:/root/.pyenv/shims:${PATH}"
ENV PANDA_PATH=/tmp/openpilot/panda
ENV OPENPILOT_REF="80bbba14f74e57bbe90216dfd0a99f6f68d77ca2"
ENV OPENDBC_REF="5880fbbccf5a670631b51836f20e446de643795a"
COPY requirements.txt /tmp/
RUN pyenv install 3.11.4 && \
pyenv global 3.11.4 && \
pyenv rehash && \
pip install --no-cache-dir -r /tmp/requirements.txt
ENV CPPCHECK_DIR=/tmp/cppcheck
COPY tests/misra/install.sh /tmp/
RUN /tmp/install.sh
RUN git config --global --add safe.directory /tmp/openpilot/panda
RUN cd /tmp && \
git clone https://github.com/commaai/openpilot.git tmppilot || true && \
cd /tmp/tmppilot && \
git fetch origin $OPENPILOT_REF && \
git checkout $OPENPILOT_REF && \
git submodule update --init cereal opendbc rednose_repo body && \
git -C opendbc fetch && \
git -C opendbc checkout $OPENDBC_REF && \
git -C opendbc reset --hard HEAD && \
git -C opendbc clean -xfd && \
mkdir /tmp/openpilot && \
cp -pR SConstruct site_scons/ tools/ selfdrive/ system/ common/ cereal/ opendbc/ rednose/ third_party/ body/ /tmp/openpilot && \
rm -rf /tmp/openpilot/panda && \
rm -rf /tmp/tmppilot
RUN cd /tmp/openpilot && \
git clone https://github.com/commaai/panda_jungle.git && \
cd panda_jungle && \
git fetch && \
git checkout 3a791be1f1877a69cf45de16a670992380622297 && \
rm -rf .git/
RUN cd /tmp/openpilot && \
pip install --no-cache-dir -r opendbc/requirements.txt && \
pip install --no-cache-dir --upgrade aenum lru-dict pycurl tenacity atomicwrites serial smbus2
# for Jenkins
COPY README.md panda.tar.* /tmp/
RUN mkdir /tmp/openpilot/panda && \
tar -xvf /tmp/panda.tar.gz -C /tmp/openpilot/panda/ || true

152
panda/Jenkinsfile vendored Normal file
View File

@@ -0,0 +1,152 @@
def docker_run(String step_label, int timeout_mins, String cmd) {
timeout(time: timeout_mins, unit: 'MINUTES') {
sh script: "docker run --rm --privileged \
--env PARTIAL_TESTS=${env.PARTIAL_TESTS} \
--env PYTHONWARNINGS=error \
--volume /dev/bus/usb:/dev/bus/usb \
--volume /var/run/dbus:/var/run/dbus \
--workdir /tmp/openpilot/panda \
--net host \
${env.DOCKER_IMAGE_TAG} \
bash -c 'scons -j8 && ${cmd}'", \
label: step_label
}
}
def phone(String ip, String step_label, String cmd) {
withCredentials([file(credentialsId: 'id_rsa', variable: 'key_file')]) {
def ssh_cmd = """
ssh -tt -o StrictHostKeyChecking=no -i ${key_file} 'comma@${ip}' /usr/bin/bash <<'END'
set -e
source ~/.bash_profile
if [ -f /etc/profile ]; then
source /etc/profile
fi
export CI=1
export TEST_DIR=${env.TEST_DIR}
export SOURCE_DIR=${env.SOURCE_DIR}
export GIT_BRANCH=${env.GIT_BRANCH}
export GIT_COMMIT=${env.GIT_COMMIT}
export PYTHONPATH=${env.TEST_DIR}/../
export PYTHONWARNINGS=error
cd ${env.TEST_DIR} || true
${cmd}
exit 0
END"""
sh script: ssh_cmd, label: step_label
}
}
def phone_steps(String device_type, steps) {
lock(resource: "", label: device_type, inversePrecedence: true, variable: 'device_ip', quantity: 1) {
timeout(time: 20, unit: 'MINUTES') {
phone(device_ip, "git checkout", readFile("tests/setup_device_ci.sh"),)
steps.each { item ->
phone(device_ip, item[0], item[1])
}
}
}
}
pipeline {
agent any
environment {
CI = "1"
//PARTIAL_TESTS = "${env.BRANCH_NAME == 'master' ? ' ' : '1'}"
PYTHONWARNINGS= "error"
DOCKER_IMAGE_TAG = "panda:build-${env.GIT_COMMIT}"
TEST_DIR = "/data/panda"
SOURCE_DIR = "/data/panda_source/"
}
options {
timeout(time: 3, unit: 'HOURS')
disableConcurrentBuilds(abortPrevious: env.BRANCH_NAME != 'master')
}
stages {
stage('panda tests') {
parallel {
stage('test dos') {
agent { docker { image 'ghcr.io/commaai/alpine-ssh'; args '--user=root' } }
steps {
phone_steps("panda-dos", [
["build", "scons -j4"],
["flash", "cd tests/ && ./reflash_internal_panda.py"],
["test", "cd tests/hitl && HW_TYPES=6 pytest --durations=0 [2-7]*.py -k 'not test_send_recv'"],
])
}
}
stage('test tres') {
agent { docker { image 'ghcr.io/commaai/alpine-ssh'; args '--user=root' } }
steps {
phone_steps("panda-tres", [
["build", "scons -j4"],
["flash", "cd tests/ && ./reflash_internal_panda.py"],
["test", "cd tests/hitl && HW_TYPES=9 pytest --durations=0 2*.py [5-9]*.py"],
])
}
}
stage ('Acquire resource locks') {
options {
lock(resource: "pandas")
}
stages {
stage('Build Docker Image') {
steps {
timeout(time: 20, unit: 'MINUTES') {
script {
sh 'git archive -v -o panda.tar.gz --format=tar.gz HEAD'
dockerImage = docker.build("${env.DOCKER_IMAGE_TAG}")
}
}
}
}
stage('prep') {
steps {
script {
retry (3) {
docker_run("reset hardware", 3, "python ./tests/ci_reset_hw.py")
}
}
}
}
stage('pedal tests') {
steps {
script {
docker_run("test pedal", 1, "PEDAL_JUNGLE=058010800f51363038363036 python ./tests/pedal/test_pedal.py")
}
}
}
stage('HITL tests') {
steps {
script {
docker_run("HITL tests", 35, 'PANDAS_JUNGLE=23002d000851393038373731 PANDAS_EXCLUDE="1d0002000c51303136383232 2f002e000c51303136383232" ./tests/hitl/test.sh')
}
}
}
stage('CANFD tests') {
steps {
script {
docker_run("CANFD tets", 6, 'JUNGLE=058010800f51363038363036 H7_PANDAS_EXCLUDE="080021000c51303136383232 33000e001051393133353939" ./tests/canfd/test_canfd.py')
}
}
}
}
}
}
}
}
}

7
panda/LICENSE Normal file
View File

@@ -0,0 +1,7 @@
Copyright (c) 2016, Comma.ai, Inc.
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

123
panda/README.md Normal file
View File

@@ -0,0 +1,123 @@
# Welcome to panda
[panda](http://github.com/commaai/panda) is the nicest universal car interface ever.
<a href="https://comma.ai/shop/products/panda-obd-ii-dongle"><img src="https://github.com/commaai/panda/blob/master/panda.png?raw=true"></a>
It supports 3x CAN, 2x LIN, and 1x GMLAN. It also charges a phone. On the computer side, it has USB.
It uses an [STM32F413](http://www.st.com/en/microcontrollers/stm32f413-423.html?querycriteria=productId=LN2004).
![panda tests](https://github.com/commaai/panda/workflows/tests/badge.svg)
![panda drivers](https://github.com/commaai/panda/workflows/drivers/badge.svg)
## Usage
Setup dependencies:
```bash
# Ubuntu
sudo apt-get install dfu-util gcc-arm-none-eabi python3-pip libffi-dev git
```
```bash
# macOS
brew install --cask gcc-arm-embedded
brew install python3 dfu-util gcc@12
```
Clone panda repository:
``` bash
git clone https://github.com/commaai/panda.git
cd panda
```
Install requirements:
```bash
pip install -r requirements.txt
```
Install library:
``` bash
python setup.py install
```
See [the Panda class](https://github.com/commaai/panda/blob/master/python/__init__.py) for how to interact with the panda.
For example, to receive CAN messages:
``` python
>>> from panda import Panda
>>> panda = Panda()
>>> panda.can_recv()
```
And to send one on bus 0:
``` python
>>> panda.can_send(0x1aa, "message", 0)
```
Note that you may have to setup [udev rules](https://github.com/commaai/panda/tree/master/drivers/linux) for Linux, such as
``` bash
sudo tee /etc/udev/rules.d/11-panda.rules <<EOF
SUBSYSTEM=="usb", ATTRS{idVendor}=="bbaa", ATTRS{idProduct}=="ddcc", MODE="0666"
SUBSYSTEM=="usb", ATTRS{idVendor}=="bbaa", ATTRS{idProduct}=="ddee", MODE="0666"
EOF
sudo udevadm control --reload-rules && sudo udevadm trigger
```
The panda jungle uses different udev rules. See [the repo](https://github.com/commaai/panda_jungle#udev-rules) for instructions.
## Software interface support
As a universal car interface, it should support every reasonable software interface.
- [Python library](https://github.com/commaai/panda/tree/master/python)
- [C++ library](https://github.com/commaai/openpilot/tree/master/selfdrive/boardd)
- [socketcan in kernel](https://github.com/commaai/panda/tree/master/drivers/linux) (alpha)
- [Windows J2534](https://github.com/commaai/panda/tree/master/drivers/windows)
## Directory structure
```
.
├── board # Code that runs on the STM32
├── drivers # Drivers (not needed for use with python)
├── python # Python userspace library for interfacing with the panda
├── tests # Tests and helper programs for panda
```
## Programming
See `board/README.md`
## Debugging
To print out the serial console from the STM32, run `tests/debug_console.py`
## Safety Model
When a panda powers up, by default it's in `SAFETY_SILENT` mode. While in `SAFETY_SILENT` mode, the buses are also forced to be silent. In order to send messages, you have to select a safety mode. Currently, setting safety modes is only supported over USB. Some of safety modes (for example `SAFETY_ALLOUTPUT`) are disabled in release firmwares. In order to use them, compile and flash your own build.
Safety modes optionally supports `controls_allowed`, which allows or blocks a subset of messages based on a customizable state in the board.
## Code Rigor
The panda firmware is written for its use in conjuction with [openpilot](https://github.com/commaai/openpilot). The panda firmware, through its safety model, provides and enforces the
[openpilot safety](https://github.com/commaai/openpilot/blob/master/docs/SAFETY.md). Due to its critical function, it's important that the application code rigor within the `board` folder is held to high standards.
These are the [CI regression tests](https://github.com/commaai/panda/actions) we have in place:
* A generic static code analysis is performed by [cppcheck](https://github.com/danmar/cppcheck/).
* In addition, [cppcheck](https://github.com/danmar/cppcheck/) has a specific addon to check for [MISRA C:2012](https://www.misra.org.uk/MISRAHome/MISRAC2012/tabid/196/Default.aspx) violations. See [current coverage](https://github.com/commaai/panda/blob/master/tests/misra/coverage_table).
* Compiler options are relatively strict: the flags `-Wall -Wextra -Wstrict-prototypes -Werror` are enforced.
* The [safety logic](https://github.com/commaai/panda/tree/master/board/safety) is tested and verified by [unit tests](https://github.com/commaai/panda/tree/master/tests/safety) for each supported car variant.
* A recorded drive for each supported car variant is [replayed through the safety logic](https://github.com/commaai/panda/tree/master/tests/safety_replay)
to ensure that the behavior remains unchanged.
* An internal Hardware-in-the-loop test, which currently only runs on pull requests opened by comma.ai's organization members, verifies the following functionalities:
* compiling the code and flashing it through USB.
* receiving, sending, and forwarding CAN messages on all buses, over USB.
In addition, we run the [pylint](https://www.pylint.org/) and [flake8](https://github.com/PyCQA/flake8) linters on all python files within the panda repo.
## Hardware
Check out the hardware [guide](https://github.com/commaai/panda/blob/master/docs/guide.pdf)
## Licensing
panda software is released under the MIT license unless otherwise specified.

6
panda/__init__.py Normal file
View File

@@ -0,0 +1,6 @@
from .python.constants import McuType, BASEDIR, FW_PATH, USBPACKET_MAX_SIZE # noqa: F401
from .python.spi import PandaSpiException, PandaProtocolMismatch # noqa: F401
from .python.serial import PandaSerial # noqa: F401
from .python import (Panda, PandaDFU, # noqa: F401
pack_can_buffer, unpack_can_buffer, calculate_checksum, unpack_log,
DLC_TO_LEN, LEN_TO_DLC, ALTERNATIVE_EXPERIENCE, CANPACKET_HEAD_SIZE)

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 39 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 21 KiB

BIN
panda/docs/guide.pdf Normal file

Binary file not shown.

View File

@@ -0,0 +1,18 @@
VERSION=0.0.1
obj-m+=panda.o
link:
sudo dkms add `pwd`
build:
sudo dkms build panda/$(VERSION)
install:
sudo dkms install panda/$(VERSION)
all: build install
uninstall:
sudo dkms uninstall panda/$(VERSION)
sudo dkms remove panda/$(VERSION) --all

View File

@@ -0,0 +1,29 @@
# Linux driver
Installs the panda linux kernel driver using DKMS.
This will allow the panda to work with tools such as `can-utils`
## Prerequisites
- `apt-get install dkms gcc linux-headers-$(uname -r) make sudo`
## Installation
- `make link` (only needed the first time. It will report an error on subsequent attempts to link)
- `make all`
- `make install`
## Uninstall
- `make uninstall`
## Usage
You will need to bring it up using `sudo ifconfig can0 up` or
`sudo ip link set dev can0 up`, depending on your platform.
Note that you may have to setup udev rules for Linux
``` bash
sudo tee /etc/udev/rules.d/11-panda.rules <<EOF
SUBSYSTEM=="usb", ATTRS{idVendor}=="bbaa", ATTRS{idProduct}=="ddcc", MODE="0666"
SUBSYSTEM=="usb", ATTRS{idVendor}=="bbaa", ATTRS{idProduct}=="ddee", MODE="0666"
EOF
sudo udevadm control --reload-rules && sudo udevadm trigger
```

View File

@@ -0,0 +1,6 @@
PACKAGE_NAME="panda"
PACKAGE_VERSION="0.0.1"
BUILT_MODULE_NAME[0]="panda"
DEST_MODULE_LOCATION[0]="/kernel/drivers/net/panda/"
AUTOINSTALL="yes"

View File

@@ -0,0 +1,2 @@
all:
gcc main.c -o cantest -pthread -lpthread

View File

@@ -0,0 +1,4 @@
#!/usr/bin/env bash
sudo ifconfig can0 up
make
./cantest

View File

@@ -0,0 +1,14 @@
obj-m += spidev_panda.o
KDIR := /lib/modules/$(shell uname -r)/build
PWD := $(shell pwd)
# GCC9 bug, apply kernel patch instead?
# https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=0b999ae3614d09d97a1575936bcee884f912b10e
ccflags-y := -Wno-missing-attributes
default:
$(MAKE) -C $(KDIR) M=$(PWD) modules
clean:
$(MAKE) -C $(KDIR) M=$(PWD) clean

27
panda/drivers/spi/load.sh Executable file
View File

@@ -0,0 +1,27 @@
#!/bin/bash
set -e
DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null && pwd)"
cd $DIR
make -j8
sudo su -c "echo spi0.0 > /sys/bus/spi/drivers/spidev/unbind" || true
sudo dmesg -C
#sudo rmmod -f spidev_panda
sudo rmmod spidev_panda || true
sudo insmod spidev_panda.ko
sudo su -c "echo 'file $DIR/spidev_panda.c +p' > /sys/kernel/debug/dynamic_debug/control"
sudo su -c "echo 'file $DIR/spi_panda.h +p' > /sys/kernel/debug/dynamic_debug/control"
sudo lsmod
echo "loaded"
ls -la /dev/spi*
sudo chmod 666 /dev/spi*
ipython -c "from panda import Panda; print(Panda.list())"
KERN=1 ipython -c "from panda import Panda; print(Panda.list())"
dmesg

33
panda/drivers/spi/patch Normal file
View File

@@ -0,0 +1,33 @@
53c53,54
< #define SPIDEV_MAJOR 153 /* assigned */
---
> int SPIDEV_MAJOR = 0;
> //#define SPIDEV_MAJOR 153 /* assigned */
354a356,358
>
> #include "spi_panda.h"
>
413,414c417,419
< retval = __put_user((spi->mode & SPI_LSB_FIRST) ? 1 : 0,
< (__u8 __user *)arg);
---
> retval = panda_transfer(spidev, spi, arg);
> //retval = __put_user((spi->mode & SPI_LSB_FIRST) ? 1 : 0,
> // (__u8 __user *)arg);
697,698d701
< { .compatible = "rohm,dh2228fv" },
< { .compatible = "lineartechnology,ltc2488" },
831c834
< .name = "spidev",
---
> .name = "spidev_panda",
856c859
< status = register_chrdev(SPIDEV_MAJOR, "spi", &spidev_fops);
---
> status = register_chrdev(0, "spi", &spidev_fops);
860c863,865
< spidev_class = class_create(THIS_MODULE, "spidev");
---
> SPIDEV_MAJOR = status;
>
> spidev_class = class_create(THIS_MODULE, "spidev_panda");

12
panda/drivers/spi/pull-src.sh Executable file
View File

@@ -0,0 +1,12 @@
#!/usr/bin/bash
set -e
DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null && pwd)"
cd $DIR
rm -f spidev.c
wget https://raw.githubusercontent.com/commaai/agnos-kernel-sdm845/master/drivers/spi/spidev.c
# diff spidev.c spidev_panda.c > patch
# git diff --no-index spidev.c spidev_panda.c
patch -o spidev_panda.c spidev.c -i patch

View File

@@ -0,0 +1,160 @@
#include <linux/delay.h>
#include <linux/spi/spi.h>
#include <linux/spi/spidev.h>
#define SPI_SYNC 0x5AU
#define SPI_HACK 0x79U
#define SPI_DACK 0x85U
#define SPI_NACK 0x1FU
#define SPI_CHECKSUM_START 0xABU
struct __attribute__((packed)) spi_header {
u8 sync;
u8 endpoint;
uint16_t tx_len;
uint16_t max_rx_len;
};
struct spi_panda_transfer {
__u64 rx_buf;
__u64 tx_buf;
__u32 tx_length;
__u32 rx_length_max;
__u32 timeout;
__u8 endpoint;
__u8 expect_disconnect;
};
static u8 panda_calc_checksum(u8 *buf, u16 length) {
int i;
u8 checksum = SPI_CHECKSUM_START;
for (i = 0U; i < length; i++) {
checksum ^= buf[i];
}
return checksum;
}
static long panda_wait_for_ack(struct spidev_data *spidev, u8 ack_val, u8 length) {
int i;
int ret;
for (i = 0; i < 1000; i++) {
ret = spidev_sync_read(spidev, length);
if (ret < 0) {
return ret;
}
if (spidev->rx_buffer[0] == ack_val) {
return 0;
} else if (spidev->rx_buffer[0] == SPI_NACK) {
return -2;
}
if (i > 20) usleep_range(10, 20);
}
return -1;
}
static long panda_transfer_raw(struct spidev_data *spidev, struct spi_device *spi, unsigned long arg) {
u16 rx_len;
long retval = -1;
struct spi_header header;
struct spi_panda_transfer pt;
struct spi_transfer t = {
.len = 0,
.tx_buf = spidev->tx_buffer,
.rx_buf = spidev->rx_buffer,
.speed_hz = spidev->spi->max_speed_hz,
};
struct spi_message m;
spi_message_init(&m);
spi_message_add_tail(&t, &m);
// read struct from user
if (!access_ok(VERIFY_WRITE, arg, sizeof(pt))) {
return -1;
}
if (copy_from_user(&pt, (void __user *)arg, sizeof(pt))) {
return -1;
}
dev_dbg(&spi->dev, "ep: %d, tx len: %d\n", pt.endpoint, pt.tx_length);
// send header
header.sync = 0x5a;
header.endpoint = pt.endpoint;
header.tx_len = pt.tx_length;
header.max_rx_len = pt.rx_length_max;
memcpy(spidev->tx_buffer, &header, sizeof(header));
spidev->tx_buffer[sizeof(header)] = panda_calc_checksum(spidev->tx_buffer, sizeof(header));
t.len = sizeof(header) + 1;
retval = spidev_sync(spidev, &m);
if (retval < 0) {
dev_dbg(&spi->dev, "spi xfer failed %ld\n", retval);
return retval;
}
// wait for ACK
retval = panda_wait_for_ack(spidev, SPI_HACK, 1);
if (retval < 0) {
dev_dbg(&spi->dev, "no header ack %ld\n", retval);
return retval;
}
// send data
dev_dbg(&spi->dev, "sending data\n");
retval = copy_from_user(spidev->tx_buffer, (const u8 __user *)(uintptr_t)pt.tx_buf, pt.tx_length);
spidev->tx_buffer[pt.tx_length] = panda_calc_checksum(spidev->tx_buffer, pt.tx_length);
t.len = pt.tx_length + 1;
retval = spidev_sync(spidev, &m);
if (pt.expect_disconnect) {
return 0;
}
// wait for ACK
retval = panda_wait_for_ack(spidev, SPI_DACK, 3);
if (retval < 0) {
dev_dbg(&spi->dev, "no data ack\n");
return retval;
}
// get response
t.rx_buf = spidev->rx_buffer + 3;
rx_len = (spidev->rx_buffer[2] << 8) | (spidev->rx_buffer[1]);
dev_dbg(&spi->dev, "rx len %u\n", rx_len);
if (rx_len > pt.rx_length_max) {
dev_dbg(&spi->dev, "RX len greater than max\n");
return -1;
}
// do the read
t.len = rx_len + 1;
retval = spidev_sync(spidev, &m);
if (retval < 0) {
dev_dbg(&spi->dev, "spi xfer failed %ld\n", retval);
return retval;
}
if (panda_calc_checksum(spidev->rx_buffer, 3 + rx_len + 1) != 0) {
dev_dbg(&spi->dev, "bad checksum\n");
return -1;
}
retval = copy_to_user((u8 __user *)(uintptr_t)pt.rx_buf, spidev->rx_buffer + 3, rx_len);
return rx_len;
}
static long panda_transfer(struct spidev_data *spidev, struct spi_device *spi, unsigned long arg) {
int i;
int ret;
dev_dbg(&spi->dev, "=== XFER start ===\n");
for (i = 0; i < 20; i++) {
ret = panda_transfer_raw(spidev, spi, arg);
if (ret >= 0) {
break;
}
}
dev_dbg(&spi->dev, "took %d tries\n", i+1);
return ret;
}

View File

@@ -0,0 +1,178 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{D99E2FCD-21A4-4065-949A-31E34E0E69D1}</ProjectGuid>
<Keyword>Win32Proj</Keyword>
<RootNamespace>ECUsimCLI</RootNamespace>
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="Shared">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<LinkIncremental>true</LinkIncremental>
<OutDir>$(SolutionDir)$(Configuration)_$(PlatformShortName)\</OutDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<LinkIncremental>true</LinkIncremental>
<OutDir>$(SolutionDir)$(Configuration)_$(PlatformShortName)\</OutDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LinkIncremental>false</LinkIncremental>
<OutDir>$(SolutionDir)$(Configuration)_$(PlatformShortName)\</OutDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<LinkIncremental>false</LinkIncremental>
<OutDir>$(SolutionDir)$(Configuration)_$(PlatformShortName)\</OutDir>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<PrecompiledHeader>Use</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<SDLCheck>true</SDLCheck>
<AdditionalIncludeDirectories>%(AdditionalIncludeDirectories);$(SolutionDir)</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);$(OutDir)ecusim.lib</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<PrecompiledHeader>Use</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<SDLCheck>true</SDLCheck>
<AdditionalIncludeDirectories>%(AdditionalIncludeDirectories);$(SolutionDir)</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);$(OutDir)ecusim.lib</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<PrecompiledHeader>Use</PrecompiledHeader>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<SDLCheck>true</SDLCheck>
<AdditionalIncludeDirectories>%(AdditionalIncludeDirectories);$(SolutionDir)</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);$(OutDir)ecusim.lib</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<PrecompiledHeader>Use</PrecompiledHeader>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<SDLCheck>true</SDLCheck>
<AdditionalIncludeDirectories>%(AdditionalIncludeDirectories);$(SolutionDir)</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);$(OutDir)ecusim.lib</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClInclude Include="..\ECUsim DLL\ECUsim.h" />
<ClInclude Include="stdafx.h" />
<ClInclude Include="targetver.h" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="ECUsim CLI.cpp" />
<ClCompile Include="stdafx.cpp">
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Create</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Create</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Create</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Create</PrecompiledHeader>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\ECUsim DLL\ECUsim DLL.vcxproj">
<Project>{96e0e646-ee76-444d-9a77-a0cd7f781deb}</Project>
</ProjectReference>
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

View File

@@ -0,0 +1,36 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="Source Files">
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
</Filter>
<Filter Include="Header Files">
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
<Extensions>h;hh;hpp;hxx;hm;inl;inc;xsd</Extensions>
</Filter>
<Filter Include="Resource Files">
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
</Filter>
</ItemGroup>
<ItemGroup>
<ClInclude Include="stdafx.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="targetver.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\ECUsim DLL\ECUsim.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="stdafx.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="ECUsim CLI.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
</Project>

View File

@@ -0,0 +1,15 @@
// stdafx.h : include file for standard system include files,
// or project specific include files that are used frequently, but
// are changed infrequently
//
#pragma once
#include "targetver.h"
#include <stdio.h>
#include <tchar.h>
// TODO: reference additional headers your program requires here

View File

@@ -0,0 +1,8 @@
#pragma once
// Including SDKDDKVer.h defines the highest available Windows platform.
// If you wish to build your application for a previous Windows platform, include WinSDKVer.h and
// set the _WIN32_WINNT macro to the platform you wish to support before including SDKDDKVer.h.
#include <SDKDDKVer.h>

View File

@@ -0,0 +1,197 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{96E0E646-EE76-444D-9A77-A0CD7F781DEB}</ProjectGuid>
<Keyword>Win32Proj</Keyword>
<RootNamespace>ECUsimDLL</RootNamespace>
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="Shared">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<LinkIncremental>true</LinkIncremental>
<TargetName>ecusim</TargetName>
<OutDir>$(SolutionDir)$(Configuration)_$(PlatformShortName)\</OutDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<LinkIncremental>true</LinkIncremental>
<TargetName>ecusim</TargetName>
<OutDir>$(SolutionDir)$(Configuration)_$(PlatformShortName)\</OutDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LinkIncremental>false</LinkIncremental>
<TargetName>ecusim</TargetName>
<OutDir>$(SolutionDir)$(Configuration)_$(PlatformShortName)\</OutDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<LinkIncremental>false</LinkIncremental>
<TargetName>ecusim</TargetName>
<OutDir>$(SolutionDir)$(Configuration)_$(PlatformShortName)\</OutDir>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<PrecompiledHeader>Use</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;_USRDLL;ECUSIMDLL_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<SDLCheck>true</SDLCheck>
<AdditionalIncludeDirectories>%(AdditionalIncludeDirectories);$(SolutionDir)</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);$(OutDir)panda.lib</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<PrecompiledHeader>Use</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>_DEBUG;_WINDOWS;_USRDLL;ECUSIMDLL_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<SDLCheck>true</SDLCheck>
<AdditionalIncludeDirectories>%(AdditionalIncludeDirectories);$(SolutionDir)</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);$(OutDir)panda.lib</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<PrecompiledHeader>Use</PrecompiledHeader>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;ECUSIMDLL_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<SDLCheck>true</SDLCheck>
<AdditionalIncludeDirectories>%(AdditionalIncludeDirectories);$(SolutionDir)</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);$(OutDir)panda.lib</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<PrecompiledHeader>Use</PrecompiledHeader>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>NDEBUG;_WINDOWS;_USRDLL;ECUSIMDLL_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<SDLCheck>true</SDLCheck>
<AdditionalIncludeDirectories>%(AdditionalIncludeDirectories);$(SolutionDir)</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);$(OutDir)panda.lib</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClInclude Include="..\panda\panda.h" />
<ClInclude Include="ECUsim.h" />
<ClInclude Include="stdafx.h" />
<ClInclude Include="targetver.h" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="dllmain.cpp">
<CompileAsManaged Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">false</CompileAsManaged>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
</PrecompiledHeader>
<CompileAsManaged Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">false</CompileAsManaged>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
</PrecompiledHeader>
<CompileAsManaged Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</CompileAsManaged>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
</PrecompiledHeader>
<CompileAsManaged Condition="'$(Configuration)|$(Platform)'=='Release|x64'">false</CompileAsManaged>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
</PrecompiledHeader>
</ClCompile>
<ClCompile Include="ECUsim.cpp" />
<ClCompile Include="stdafx.cpp">
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Create</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Create</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Create</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Create</PrecompiledHeader>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\panda\panda.vcxproj">
<Project>{5528aefb-638d-49af-b9d4-965154e7d531}</Project>
</ProjectReference>
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

View File

@@ -0,0 +1,42 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="Source Files">
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
</Filter>
<Filter Include="Header Files">
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
<Extensions>h;hh;hpp;hxx;hm;inl;inc;xsd</Extensions>
</Filter>
<Filter Include="Resource Files">
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
</Filter>
</ItemGroup>
<ItemGroup>
<ClInclude Include="stdafx.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="targetver.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="ECUsim.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\panda\panda.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="stdafx.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="dllmain.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="ECUsim.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
</Project>

View File

@@ -0,0 +1,50 @@
#pragma once
#include <string>
#include "panda_shared/panda.h"
#include <queue>
// The following ifdef block is the standard way of creating macros which make exporting
// from a DLL simpler. All files within this DLL are compiled with the ECUSIMDLL_EXPORTS
// symbol defined on the command line. This symbol should not be defined on any project
// that uses this DLL. This way any other project whose source files include this file see
// ECUSIMDLL_API functions as being imported from a DLL, whereas this DLL sees symbols
// defined with this macro as being exported.
#ifdef ECUSIMDLL_EXPORTS
#define ECUSIMDLL_API __declspec(dllexport)
#else
#define ECUSIMDLL_API __declspec(dllimport)
#endif
// This class is exported from the ECUsim DLL.dll
class ECUSIMDLL_API ECUsim {
public:
ECUsim(std::string sn, unsigned long can_baud, bool ext_addr = FALSE);
ECUsim(panda::Panda && p, unsigned long can_baud, bool ext_addr = FALSE);
~ECUsim();
void stop();
void join();
// Flag determines if verbose output is enabled
volatile bool verbose;
BOOL ext_addr;
private:
std::unique_ptr<panda::Panda> panda;
static DWORD WINAPI _canthreadBootstrap(LPVOID This);
DWORD can_recv_thread_function();
BOOL _can_addr_matches(panda::PANDA_CAN_MSG & msg);
void _CAN_process_msg(panda::PANDA_CAN_MSG & msg);
std::string process_obd_msg(UCHAR mode, UCHAR pid, bool& return_data);
HANDLE thread_can;
volatile bool doloop;
std::queue<uint8_t> can_multipart_data;
BOOL can11b_enabled;
BOOL can29b_enabled;
};

View File

@@ -0,0 +1,16 @@
// stdafx.h : include file for standard system include files,
// or project specific include files that are used frequently, but
// are changed infrequently
//
#pragma once
#include "targetver.h"
#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
// Windows Header Files:
#include <windows.h>
// TODO: reference additional headers your program requires here

View File

@@ -0,0 +1,8 @@
#pragma once
// Including SDKDDKVer.h defines the highest available Windows platform.
// If you wish to build your application for a previous Windows platform, include WinSDKVer.h and
// set the _WIN32_WINNT macro to the platform you wish to support before including SDKDDKVer.h.
#include <SDKDDKVer.h>

View File

@@ -0,0 +1,144 @@
# Windows driver
```
;" ^; ;' ",
______/\\\\\\\\\\\____/\\\\\\\\\_______/\\\\\\\\\\\\\\\______/\\\\\\\\\\_____________/\\\____ ; s$$$$$$$s ;
_____\/////\\\///___/\\\///////\\\____\/\\\///////////_____/\\\///////\\\__________/\\\\\____ , ss$$$$$$$$$$s ,'
_________\/\\\_____\///______\//\\\___\/\\\_______________\///______/\\\_________/\\\/\\\____ ;s$$$$$$$$$$$$$$$
_________\/\\\_______________/\\\/____\/\\\\\\\\\\\\_____________/\\\//________/\\\/\/\\\____ $$$$$$$$$$$$$$$$$$
_________\/\\\____________/\\\//______\////////////\\\__________\////\\\_____/\\\/__\/\\\____ $$$$P""Y$$$Y""W$$$$$
_________\/\\\_________/\\\//____________________\//\\\____________\//\\\__/\\\\\\\\\\\\\\\\_ $$$$ p"$$$"q $$$$$
__/\\\___\/\\\_______/\\\/____________/\\\________\/\\\___/\\\______/\\\__\///////////\\\//__ $$$$ .$$$$$. $$$$
_\//\\\\\\\\\_______/\\\\\\\\\\\\\\\_\//\\\\\\\\\\\\\/___\///\\\\\\\\\/_____________\/\\\____ _ $$$$$$$$$$$$$$$$
__\/////////_______\///////////////___\/////////////_______\/////////_______________\///_____| | "Y$$$"*"$$$Y"
_ __ __ _ _ __ __| | __ _"$b.$$"
| '_ \ / _` | '_ \ / _` |/ _` |
| |_) | (_| | | | | (_| | (_| |
| .__/ \__,_|_| |_|\__,_|\__,_|
| | A comma.ai product.
|_| (Code by Jessy Diamond Exum)
```
## Installing J2534 driver
[Download](https://github.com/commaai/panda/files/4844692/panda.J2534.driver.install.zip)
Depending on what version of windows you are on, you may need to separately install the WinUSB driver (see next section).
## Installing WinUSB driver
Installation automatically happens for Windows 8 and Windows 10 because the panda
firmware contains the USB descriptors necessary to auto-install the WinUSB driver.
Windows 7 will not auto-install the WinUSB driver. You can use Zadig to install
the WinUSB driver. This software is not tested on anything before 7.
More details here:
[WinUSB (Winusb.sys) Installation](https://docs.microsoft.com/en-us/windows-hardware/drivers/usbcon/winusb-installation)
[WCID Devices](https://github.com/pbatard/libwdi/wiki/WCID-Devices)
[Zadig for installing libusb compatible driver](https://github.com/pbatard/libwdi/wiki/Zadig)
## Using J2534
After installing the J2534 drivers for the panda, you can do... nothing.
You first need to get a J2534 client that can load the drivers and talk to
the panda for you.
A simple tool for testing J2534 drivers is DrewTech's 'J2534-1 Bus Analysis
Tool' available in the 'Other Support Applications' section of their
[Download Page](http://www.drewtech.com/downloads/#OtherSupportApplications).
## What is J2534?
J2534 is an API that tries to provide a consistent way to send/receive
messages over the many different protocols supported by the OBD II
port. The place this is perhaps most obvious, is sending data over
different protocols (each using unique packetizing methods) using the
same data format.
For each PassThru Device that should be used with J2534 (in this case,
the panda), a 'driver' has to be written that can be loaded by a
client application wanting to send/receive data.
A lot of J2534 has good ideas behind it, but the standard has some odd choices:
* Platform Locked: Requires using the Windows Registry to find installed J2534 libraries/drivers. Drivers have to be DLLs.
* Architecture Locked: So far there is only support for x86.
* No device autodetect, and poor support for selecting from multiple devices.
* Constant vague language about important behavior (small differences between vendors).
* Most common differences become standard in later revisions.
## Why use J2534 with the panda?
J2534 is the only interface supported by most professional grade
vehicle diagnostics systems (such as HDS). These tools are useful for
diagnosing vehicles, as well as reverse engineering some lesser known
features.
## What parts are supported with panda?
- [ ] **J1850VPW** *(Outdated, and not physically supported by the panda)*
- [ ] **J1850PWM** *(Outdated, and not physically supported by the panda)*
- [X] **CAN**
- [X] **ISO15765**
- [X] **ISO9141**
- [X] **ISO14230/KWP2000**
## Building the Project
This project is developed with Visual Studio 2017, the Windows SDK,
and the Windows Driver Kit (WDK).
The WDK is only required for creating the signed WinUSB inf file. The
WDK may also provide the headers for WinUSB.
To build all the projects required for the installer, in Visual
Studio, select **Build->Batch Build.** In the project list select:
- **"panda"** *Release|x86*
- **"panda"** *Release|x64*
- **"panda Driver Package"** Debug|x86 (Note this inf file works with x86/amd64).
- **"pandaJ2534DLL"** *Release|x86*
The installer is generated with [NullSoft NSIS](http://nsis.sourceforge.net/Main_Page).
Use NSIS to run panda_install.nsi after building all the required projects.
Before generating the installer, you must go to copy vscruntimeinfo.nsh.sample to
vscruntimeinfo.nsh and follow the instructions to bundle in the Visual Studio C
Runtime required by your version of Visual Studio. Without this runtime, the panda
code will not work, so without this file, the installer will refuse to build.
## Developing
- Edit and merge pandaJ2534DLL\J2534register_x64.reg to register your development J2534 DLL.
- Add your output directory (panda\drivers\windows\Debug_x86) to your system PATH to avoid insanity.
## ToDo Items
- Apply a style-guide and consistent naming convention for Classes/Functions/Variables.
- Send multiple messages (each with a different address) from a given connection at the same time.
- Find more documentation about SW_CAN_PS (Single Wire CAN, aka GMLAN).
- Find example of client using a _PS version of a protocol (PS is pin select, and may support using different CAN buses).
## Known Issues
- ISO15765 Multi-frame TX: Hardware delays make transmission overshoot
STMIN by several milliseconds. This does not violate the requirements
of STMIN, it just means it is a little slower than it could be.
- All Tx messages from a single Connection are serialized. This can be
relaxed to allow serialization of messages based on their address
(making multiple queues, effectively one queue per address).
## Troubleshooting
troubleshooting:
1. Install DrewTech J2534-1 Bus Analysis Tool
http://www.drewtech.com/downloads/tools/Drew%20Technologies%20Tool%20for%20J2534-1%20API%20v1.07.msi
2. Open DrewTech tool and make sure it shows "panda" as a device listed (this means registry settings are correct)
3. When DrewTech tool attempts to load the driver it will show an error if it fails
4. To figure out why the driver fails to load install Process Monitor and filter by the appropriate process name
https://docs.microsoft.com/en-us/sysinternals/downloads/procmon
## Other
Panda head ASCII art by dcau

Binary file not shown.

After

Width:  |  Height:  |  Size: 56 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 348 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 112 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 107 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 56 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 44 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 93 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 109 KiB

View File

@@ -0,0 +1,347 @@
When using the ISO 15765-4 protocol, only SingleFrame messages can be transmitted without a matching
flow control filter. Also, PCI bytes are transparently added by the API. See PassThruStartMsgFilter
and Appendix A for a discussion of flow control filters.
PassThruReadMsgs
This function reads messages and indications from the receive buffer. All messages and indications shall
be read in the order that they occurred on the bus. If a transmit message generated a loopback message
and TxDone indication, the TxDone indication shall always be queued first. Except for loopback messages
and indications, no messages shall be queued for reception without matching a PASS_FILTER
(for non-ISO 15765) or FLOW_CONTROL filter (for ISO 15765). On ISO 15765, PCI bytes are transparently
removed by the API. If the function is successful, a value of STATUS_NOERROR is returned.
PassThruWriteMsgs
Write timeout (in milliseconds). When a value of 0 is specified, the function queues as
many of the specified messages as possible and returns immediately. When a value
greater than 0 is specified, the function will block until the Timeout has expired, an error
has occurred, or the desired number of messages have been transmitted on the vehicle
network. Even if the device can buffer only one packet at a time, this function shall be
able to send an arbitrary number of packets if a Timeout value is supplied. Since the
function returns early if all the messages have been sent, there is normally no penalty for
having a large timeout (several seconds). If the number of messages requested have
been written, the function shall not return ERR_TIMEOUT, even if the timeout value is
zero.
When an ERR_TIMEOUT is returned, only the number of messages that were sent on
the vehicle network is known. The number of messages queued is unknown. Application
writers should avoid this ambiguity by using a Timeout value large enough to work on
slow devices and networks with arbitration delays.
PassThruStartPeriodicMsg
This function will immediately queue the specified message for transmission, and repeat at the specified
interval. Periodic messages are limited in length to a single frame message of 12 bytes or less, including
header or CAN ID. Periodic messages shall have priority over messages queued with
PassThruWriteMsgs, but periodic messages must not violate bus idle timing parameters (e.g. P3_MIN).
Periodic messages shall generate TxDone indications (ISO 15765) and loopback messages (on any
protocol, if enabled). On ISO 15765, periodic messages can be sent during a multi-frame transmission or
reception. If the function is successful, a value of STATUS_NOERROR is returned. The Pass-Thru
device must support a minimum of ten periodic messages.
PassThruDisconnect shall delete all periodic messages on that channel. PassThruClose shall delete all
periodic messages on all channels for the device. All periodic messages will be stopped on a
PassThruDisconnect for the associated protocol or a PassThruClose for the device.
PASSTHRUSTARTMSGFILTER
This function starts filtering of incoming messages. If the function is successful, a value of
STATUS_NOERROR is returned. A minimum of ten message filters shall be supported by the interface
for each supported protocol. PassThruDisconnect shall delete all message filters on that channel.
PassThruClose shall delete all filters on all channels for the device. Pattern and Mask messages shall
follow the protocol formats specified in Section 8. However, only the first twelve (12) bytes, including
header or CAN ID, are used by the filter. ERR_INVALID_MSG shall be returned if the filter length
exceeds 12. Note that this function does not clear any messages that may have been received and
queued before the filter was set. Users are cautioned to consider performing a CLEAR_RX_BUFFER
after starting a message filter to be sure that unwanted frames are purged from any receive buffers.
FILTER RELATED STUFF
For all protocols except ISO 15765:
• PASS_FILTERs and BLOCK_FILTERs will be applied to all received messages. They shall not be
applied to indications or loopback messages
• FLOW_CONTROL_FILTERs must not be used and shall cause the interface to return
ERR_INVALID_FILTER_ID
• Both pMaskMsg and pPatternMsg must have the same DataSize and TxFlags. Otherwise, the
interface shall return ERR_INVALID_MSG
• The default filter behavior after PassThruConnect is to block all messages, which means no messages
will be placed in the receive queue until a PASS_FILTER has been set. Messages that match a
PASS_FILTER can still be blocked by a BLOCK_FILTER
• Figure 16 and Figure 17 show how the message filtering mechanism operates
For ISO 15765:
• PASS_FILTERs and BLOCK_FILTERs must not be used and shall cause the interface to return
ERR_INVALID_FILTER_ID
• Filters shall not be applied to indications or loopback messages. When loopback is on, the original
message shall be copied to the receive queue upon the last segment being transmitted on the bus.
• Non-segmented messages do not need to match a FLOW_CONTROL_FILTER.
• No segmented messages can be transmitted without matching an appropriate FLOW_CONTROL_FILTER.
An appropriate filter is one in which the pFlowControlMsg CAN ID matches the messages to be
transmitted. Also, the ISO 15765_ADDR_TYPE (reference TxFlags in Section 8.7.3) bits must match.
If that bit is set, the first byte after the CAN IDs (the extended address)
must match too.
• No message (segmented or unsegmented) shall be received without matching an appropriate
FLOW_CONTROL_FILTER. An appropriate filter is one in which the pPatternMsg CAN ID matches
the incoming message ID. If the ISO 15765_ADDR_TYPE (reference TxFlags in Section 8.7.3) bit is
set in the filter, the first byte after the CAN IDs (the extended address) must match too.
• All 3 message pointers must have the same DataSize and TxFlags. Otherwise, the interface shall
return ERR_INVALID_MSG.
• Both the pFlowControlMsg ID and the pPatternMsg ID must be unique (not match any IDs in any other
filters). The only exception is that pPatternMsg can equal pFlowControlMsg to allow for receiving
functionally addressed messages. In this case, only non-segmented messages can be received.
• See Appendix A for a detailed description of flow control filter usage.
8.4 Format Checks for Messages Passed to the API
The vendor DLL shall validate all PASSTHRU_MSG structures, and return an ERR_INVALID_MSG in the following cases:
• DataSize violates Min Tx or Max Tx columns in Figure 42
• Source address (Data[3]) is different from the Node ID (Ioctl SET_CONFIG, Parameter NODE_ADDRESS) on J1850PWM
• The header length field is incorrect for the number of bytes in the message on ISO14230
• The CAN_29_BIT flag of the message does not match the CAN_29_BIT flag passed to
PassThruConnect, unless the CAN_ID_BOTH bit was set on connect
The vendor DLL shall return ERR_MSG_PROTOCOL_ID when the ProtocolID field in the message does
not match the Protocol ID specified when opening the channel.
8.5 Conventions for Returning Messages from the API
When returning a message in PassThruReadMsg:
DataSize shall tell the application how many bytes in the Data array are valid. ExtraDataIndex will be
the (non-zero) index of the last byte of the message. If ExtraDataIndex is not equal to DataSize there
are extra data bytes after the message. If loopback is on, RxStatus must be consulted to tell if the
message came via loopback.
DataSize will be in the range shown in the Min Rx and Max Rx columns of Figure 42. If the device
receives a message from the vehicle bus that is too long or too short, the message shall be discarded
with no error.
For received messages, ExtraDataIndex shall be equal to DataSize, except when the interface is
returning SAE J1850 PWM IFR bytes. In no case shall ExtraDataIndex be larger than DataSize.
When receiving a message on an SAE J1850 PWM channel, the message shall have any IFR bytes
appended. In this case, ExtraDataIndex shall be the index of the first IFR byte, and DataSize shall be
the total length of the original message plus all IFR bytes. For example, if there are two IFR bytes,
DataSize will be incremented by two, and ExtraDataIndex will be DataSize - 2. When loopback is on,
the loopback message shall contain any IFR bytes.
8.6 Conventions for Retuning Indications from the API
When returning an indication in PassThruReadMsg:
ExtraDataIndex must be zero
DataSize shall tell the application how many bytes in the Data array are valid
RxStatus must be consulted to determine the indication type (See Section 8.4).
A TxDone indication (ISO 15765 only) is generated by the DLL after a SingleFrame message is sent,
or the last frame of a multi-segment transmission is sent. DataSize shall be 4 (or 5 when the message
was using Extended Addressing). Data shall contain the CAN ID (and possible Extended Address) of
the message just sent. If loopback is on, the TxDone indication shall precede the loopback message in
the receive queue.
An RxBreak indication (SAE J2610/SCI and SAE J1850VPW only) is generated by the DLL if a break
is received.
An RxStart indication is generated by the DLL when starting to receive a message on ISO9141 or
ISO14230, or when receiving the FirstFrame signal of a multi-segment ISO 15765 message.
9.1 Naming of Files
Each vendor will provide a different name implementation of the API DLL and a number of these
implementations could simultaneously reside on the same PC. No vendor shall name its implementation
“J2534.DLL”. All implementations shall have the string “32” suffixed to end of the name of the API DLL to
indicate 32-bit. For example, if the company name is “Vendor X” the name could be VENDRX32.DLL.
For simplicity, an API DLL shall be named in accordance with the file allocation table (FAT) file system
naming convention (which allows up to eight characters for the file name and three characters for the
extension with no spaces anywhere). Note that, given this criteria, the major name of an API DLL can be
no greater than six characters. The OEM application can determine the name of the appropriate vendors
DLL using the Win32 Registry mechanism described in this section.
A.1 Flow Control Overview
ISO 15765-2 was designed to send blocks of up to 4095 bytes on top of the limited 8-byte payload of raw
CAN frames. If the data is small enough, it can fit in a single frame and be transmitted like a raw CAN
message with additional headers. Otherwise, the block is broken up into segments and becomes a
segmented transmission, generating CAN frames in both directions. For flexibility, the receiver of the
segments can control the rate at which the segments are sent.
Each transmission is actually part of a conversation between two nodes. There is no discovery
mechanism for conversation partners. Therefore, each desired conversation must be pre-defined on each
side before the conversation can start. Conversations are symmetric, meaning that either side can send a
block of data to the other. A conversation can only have one transfer (in one direction) in progress at a
time. One transfer must complete before the next transfer (in the same or in a different direction) can
start. The device must support multiple transfers at once, as long as each one is part of a different
conversation. Raw CAN frames are not allowed when using ISO15765-2.
A key feature of a conversation is that each side has a unique CAN ID, and each side uses their unique
CAN ID for all transmissions during the conversation. No other CAN IDs are part of the conversation.
Even though the useful data is only flowing in one direction, both sides are transmitting. One side is
sending the flow control message to pace the segments of data coming from the other side.
For example, during OBD communication, a pass-thru device and an ECU might have a conversation.
The pass-thru device will use the "Tester1" physical CAN ID ($241), and the first ECU will use the
"ECU1" physical CAN ID ($641). During a multi-segment transfer, both sides will be transmitting using
only their respective IDs. It does not matter if the data is being sent by the ECU or by the Tester, the IDs
remain the same.
It is important to understand the difference between OBD Requests/Responses and ISO 15765-2
transfers. The OBD Request is transmitted from the Tester to the ECU using functional addressing.
Because segmented transfer is not possible on functional addresses, the message must fit in a single
frame. The OBD Response is a message from the ECU to the Tester using physical addressing. Unlike
other protocols, the responses are not sequential. In fact, the responses can overlap, as if each ECU
were having a private conversation with the Tester. Some of the responses may fit in a single frame,
while others will require a segmented transfer from the ECU to the tester.
A.2 Transmitting a Segmented Message
When PassThruWrite is called, the API will search the list of flow control filters, looking for a
pFlowControlMsg that matches the CAN ID (and possible extended address) of the message being sent.
Upon matching a filter, the pass-thru device will:
• Start the ISO 15765 transfer by sending a FirstFrame on the bus. The CAN ID of this segment was
specified in both the message and the matching pFlowControlMsg. In our example, this is $241.
• Wait for a FlowControl frame from the conversation partner. The CAN ID to look for is specified in the
corresponding pPatternMsg. In our example, this is $641.
• Transmit the message data in ConsecutiveFrames according to the FlowControl frames instructions
for BS (BlockSize) and STmin (SeparationTime minimum). Again, the pass-thru device transmits using
CAN ID specified in pFlowControlMsg. In our example, this is $241.
• Repeat the previous two steps as required.
• When finished, the pass-thru device will place a TxDone indication in the API receive queue. The data
will contain the CAN ID specified in pFlowControlMsg. In our example, this is $241.
• If loopback is on, the entire message sent will appear in the API receive queue with the
TX_MSG_TYPE bit set to 1 in RxStatus. The loopback shall not precede the TxDone indication.
Before any multi-segment transfer can take place, the conversation must be set up on both sides. Its
assumed that the ECU is already setup. The application is responsible for setting up the pass-thru device.
This setup must be done once (and only once) per conversation. The setup involves a single call to
PassThruStartMsgFilter, with the following parameters:
A.2.2 Data Transmission
Once the conversation is set up, any number of messages (to the conversation partner) can be
transmitted using PassThruWriteMsg. The interface shall handle all aspects of the transfer, including
pacing (slowing) the transmission to the requirements of the receiver.
When there are multiple conversations setup, the pass-thru device will search all of the flow control filters
for a matching pFlowControlMsg. If there is no match, the message cannot be sent because the pass-
thru device doesnt know which partner will be pacing the conversation.
When doing blocking writes, it is important to pick a timeout long enough to cover entire transfer, even if
the ECU is pacing things slowly. Otherwise PassThruWriteMsg will return with a timeout, even though the
transmission is proceeding normally.
A.3 Transmitting an Unsegmented Message
As a special case, transfers that fit in a single frame can be transmitted without setting up a conversation.
This is useful during an OBD Request, which is a functionally addressed message that is broadcast to all
ECUs. This message must be small enough to fit into a single frame (including headers) because it is not
possible to do one segmented transfer to multiple ECUs.
When using functional addressing for an OBD Request, it is important to remember that there can be no
direct reply. Instead, each ECU will send their OBD Response using physical addressing to their
conversation partner (e.g. ECU1 to Tester1, ECU2 to Tester2) as defined by ISO 15765-4. The OBD
Response may be a segmented transfer, or it may be a single frame.
In this case, no conversation setup is necessary. The call to PassThruWriteMsg is the same as above,
except that the DataSize must be 7 bytes or less (6 bytes or less if extended addressing is turned on).
The pass-thru device will automatically insert a PCI byte before transmission.
A.4 Receiving a Segmented Message
Message reception is asynchronous to the application. When a FirstFrame is seen on the bus, the pass-
thru device will search the list of flow control filters, looking for a pPatternMsg message with the same
CAN ID (and possible extended address) as the FirstFrame. Upon matching a filter, the pass-thru device will:
• Place an RxStart indication in the API receive queue. This indication has the START_OF_MESSAGE
bit set in RxFlags. The message data will contain the CAN ID of the sender. In our example, this is
$641. DataSize will be 4 bytes (5 with extended addressing), and ExtraDataIndex will be zero.
• Send a FlowControl frame to the conversation partner. The FlowStatus field shall be set to
ontinueToSend. The CAN ID of this segment comes from the filters corresponding
pFlowControlMsg. In our example, this CAN ID is $241. The BS (BlockSize) and STmin
(SeparationTime minimum) parameters default to zero, but can be changed with the SET_CONFIGIoctl.
• Wait for the conversation partner to send C
onsecutiveFrames containing the actual data. The
partners CAN ID is specified in pPatternMsg. In our example, this CAN ID is $641.
• Repeat as necessary until the entire block has been received. When finished, the pass-thru device will
put the assembled message into the API receive queue. The CAN ID of the assembled message will
be the CAN ID of the sender. In our example, this CAN ID is $641.
If the FirstFrame does not match any flow control filters, then the message must be ignored by the
device.
Segmented messages cause the API to generate an RxStart indication. This lets the application know
that the device has started message reception. It may take a while before message reception is
complete, especially if the application has increased BS and STmin.
Once the transfer is complete, the entire message can be read like on any other protocol. Usually,
applications will call PassThruReadMsg again immediately after getting an RxStart indication. Application
writers should not assume that the complete message will always follow the RxStart indication. If multiple
conversations are setup, indications and messages from other conversations can be received in between
the RxStart indication and the actual message. The parameters for PassThruReadMsg are exactly the
same as in the previous section. The only difference is that the DataSize will be larger and
ExtraDataIndex will be non-zero.
A.5 Receiving an Unsegmented Message
No messages can be received until a conversation is setup. Each conversation setup will receive
messages from exactly one CAN ID (and extended address if present). Because setup is bi-directional,
the same PassThruStartMsgFilter call used for transmission will allow for message reception.
When a SingleFrame is seen on the bus, the pass-thru device will search the list of flow control filters,
looking for a pPatternMsg message with the same C
AN ID (and possible extended address) as the
SingleFrame. Upon matching a filter, the pass-thru device will strip the PCI byte and queue the packet for
reception. If the SingleFrame does not match a flow control filter, it must be discarded.
The only difference between the previous cases is that single-frame messages do not generate an
RxStart indication.

Binary file not shown.

After

Width:  |  Height:  |  Size: 67 KiB

View File

@@ -0,0 +1,2 @@
#32 bit: HKEY_LOCAL_MACHINE\SOFTWARE\PassThruSupport
#64 bit: HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\PassThruSupport

Binary file not shown.

After

Width:  |  Height:  |  Size: 70 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 69 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 45 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 45 KiB

View File

@@ -0,0 +1,42 @@
From focum information on NI hardware: https://forums.ni.com/t5/Automotive-and-Embedded-Networks/15765-2-with-NI-products/td-p/1454256
/////////////////////////////////////////////////////////////////////
Timeout Diag Command is the timeout in milliseconds the master
waits for the response to a diagnostic request message. The default is
1000 ms.
Timeout FC (Bs) is the timeout in milliseconds the master waits
for a Flow Control frame after sending a First Frame or the last
Consecutive Frame of a block. The default is 250 ms.
Timeout CF (Cr) is the timeout in milliseconds the master waits
for a Consecutive Frame in a multiframe response. The default is
250 ms.
Receive Block Size (BS) is the number of Consecutive Frames the
slave sends in one block before waiting for the next Flow Control
frame. A value of 0 (default) means all Consecutive Frames are sent
in one run without interruption.
Wait Time CF (STmin) defines the minimum time for the slave to
wait between sending two Consecutive Frames of a block. Values
from 0 to 127 are wait times in milliseconds. Values 241 to 249
(Hex F1 to F9) mean wait times of 100 μs to 900 μs, respectively.
All other values are reserved. The default is 5 ms.
Max Wait Frames (N_WFTmax) is the maximum number of WAIT
frames the master accepts before terminating the connection. The
default is 10.
There are no defined lower limits for these values; you can specify any
value down to 0. However, as you correctly pointed out, the timing is
done by Windows, and will be subject to the jitter introduced by the OS
which can easily be in the order of 10s of milliseconds. It is however
hard to give more accurate numbers as the actual jitter is dependent on
the workload of the computer
/////////////////////////////////////////////////////////////////////
J2534 04.04 does not appear to have default adjustable parameters for
the timeout related fields. For now, these default values shall be used
in the Panda J2534 implementation.

View File

@@ -0,0 +1,99 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{BD34DB24-F5DC-4992-A74F-05FAF731ABED}</ProjectGuid>
<TemplateGuid>{a1357fe7-03e0-4d61-85f4-09c7ed38c0c1}</TemplateGuid>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<MinimumVisualStudioVersion>12.0</MinimumVisualStudioVersion>
<Configuration>$driverCurrentWindowsConfigurationName$ Debug</Configuration>
<Platform Condition="'$(Platform)' == ''">Win32</Platform>
<RootNamespace>panda_Driver_Package</RootNamespace>
<WindowsTargetPlatformVersion>$(LatestTargetPlatformVersion)</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<TargetVersion>Windows10</TargetVersion>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>WindowsKernelModeDriver10.0</PlatformToolset>
<ConfigurationType>Utility</ConfigurationType>
<DriverType>Package</DriverType>
<DisableFastUpToDateCheck>true</DisableFastUpToDateCheck>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<TargetVersion>Windows10</TargetVersion>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>WindowsKernelModeDriver10.0</PlatformToolset>
<ConfigurationType>Utility</ConfigurationType>
<DriverType>Package</DriverType>
<DisableFastUpToDateCheck>true</DisableFastUpToDateCheck>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<!-- Debug the associated application, not the WinUSB driver -->
<DebuggerFlavor>DbgengRemoteDebugger</DebuggerFlavor>
<HardwareIdString />
<CommandLine />
<DeployFiles />
<EnableVerifier>False</EnableVerifier>
<AllDrivers>False</AllDrivers>
<VerifyProjectOutput>True</VerifyProjectOutput>
<VerifyDrivers />
<VerifyFlags>133563</VerifyFlags>
<OutDir>$(SolutionDir)$(Configuration)_$(PlatformShortName)\</OutDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<!-- Debug the associated application, not the WinUSB driver -->
<DebuggerFlavor>DbgengRemoteDebugger</DebuggerFlavor>
<HardwareIdString />
<CommandLine />
<DeployFiles />
<EnableVerifier>False</EnableVerifier>
<AllDrivers>False</AllDrivers>
<VerifyProjectOutput>True</VerifyProjectOutput>
<VerifyDrivers />
<VerifyFlags>133563</VerifyFlags>
<OutDir>$(SolutionDir)$(Configuration)_$(PlatformShortName)\</OutDir>
</PropertyGroup>
<ItemGroup>
<Inf Include="panda.inf" />
<!-- Explicitly set all FilesToPackage since there is no dependency on a driver -->
<FilesToPackage Include="@(Inf->'%(CopyOutput)')" Condition="'@(Inf)'!=''" />
<FilesToPackage Condition="$(KMDF_VERSION_MAJOR) == 1 and $(KMDF_VERSION_MINOR) &lt; 13" Include="$(WDKContentRoot)redist\wdf\$(DDKPlatform)\WdfCoinstaller$(KMDF_VERSION_MAJOR_STRING)$(KMDF_VERSION_MINOR_STRING).dll" />
</ItemGroup>
<!-- INF handling depends on order. Some of the above ImportGroup nodes set up INF handling. -->
<!-- Modify INF handling here. -->
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Inf>
<!-- The WinUSB driver requires KMDF, so we must provide a KMDF version number in the INF. -->
<!-- Use the user's KMDF setting (defaults to latest) -->
<KmdfVersionNumber>$(KMDF_VERSION_MAJOR).$(KMDF_VERSION_MINOR)</KmdfVersionNumber>
</Inf>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Inf>
<!-- The WinUSB driver requires KMDF, so we must provide a KMDF version number in the INF. -->
<!-- Use the user's KMDF setting (defaults to latest) -->
<KmdfVersionNumber>$(KMDF_VERSION_MAJOR).$(KMDF_VERSION_MINOR)</KmdfVersionNumber>
</Inf>
</ItemDefinitionGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

View File

@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="Driver Files">
<UniqueIdentifier>{8E41214B-6785-4CFE-B992-037D68949A14}</UniqueIdentifier>
<Extensions>inf;inv;inx;mof;mc;</Extensions>
</Filter>
</ItemGroup>
<ItemGroup>
<Inf Include="panda.inf">
<Filter>Driver Files</Filter>
</Inf>
</ItemGroup>
</Project>

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 95 KiB

View File

@@ -0,0 +1,92 @@
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.27130.2027
MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "pandaJ2534DLL", "pandaJ2534DLL\pandaJ2534DLL.vcxproj", "{A2BB18A5-F26B-48D6-BBB5-B83D64473C77}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "panda", "panda\panda.vcxproj", "{5528AEFB-638D-49AF-B9D4-965154E7D531}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "panda_playground", "panda_playground\panda_playground.vcxproj", "{691DB635-C272-4B98-897E-0505B970DCA9}"
ProjectSection(ProjectDependencies) = postProject
{5528AEFB-638D-49AF-B9D4-965154E7D531} = {5528AEFB-638D-49AF-B9D4-965154E7D531}
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "panda Driver Package", "panda Driver Package\panda Driver Package.vcxproj", "{BD34DB24-F5DC-4992-A74F-05FAF731ABED}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Tests", "pandaJ2534DLL Test\pandaJ2534DLL Test.vcxproj", "{7912F978-B48C-4C5D-8BFD-5D1E22158E47}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ECUsim DLL", "ECUsim DLL\ECUsim DLL.vcxproj", "{96E0E646-EE76-444D-9A77-A0CD7F781DEB}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ECUsim CLI", "ECUsim CLI\ECUsim CLI.vcxproj", "{D99E2FCD-21A4-4065-949A-31E34E0E69D1}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "panda_shared", "panda_shared\panda_shared.vcxitems", "{0C843279-68C7-4679-AE51-9BC463D50D1C}"
EndProject
Global
GlobalSection(SharedMSBuildProjectFiles) = preSolution
panda_shared\panda_shared.vcxitems*{0c843279-68c7-4679-ae51-9bc463d50d1c}*SharedItemsImports = 9
panda_shared\panda_shared.vcxitems*{5528aefb-638d-49af-b9d4-965154e7d531}*SharedItemsImports = 4
panda_shared\panda_shared.vcxitems*{a2bb18a5-f26b-48d6-bbb5-b83d64473c77}*SharedItemsImports = 4
EndGlobalSection
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|x64 = Debug|x64
Debug|x86 = Debug|x86
Release|x64 = Release|x64
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{A2BB18A5-F26B-48D6-BBB5-B83D64473C77}.Debug|x64.ActiveCfg = Debug|Win32
{A2BB18A5-F26B-48D6-BBB5-B83D64473C77}.Debug|x86.ActiveCfg = Debug|Win32
{A2BB18A5-F26B-48D6-BBB5-B83D64473C77}.Debug|x86.Build.0 = Debug|Win32
{A2BB18A5-F26B-48D6-BBB5-B83D64473C77}.Release|x64.ActiveCfg = Release|Win32
{A2BB18A5-F26B-48D6-BBB5-B83D64473C77}.Release|x86.ActiveCfg = Release|Win32
{A2BB18A5-F26B-48D6-BBB5-B83D64473C77}.Release|x86.Build.0 = Release|Win32
{5528AEFB-638D-49AF-B9D4-965154E7D531}.Debug|x64.ActiveCfg = Debug|x64
{5528AEFB-638D-49AF-B9D4-965154E7D531}.Debug|x64.Build.0 = Debug|x64
{5528AEFB-638D-49AF-B9D4-965154E7D531}.Debug|x86.ActiveCfg = Debug|Win32
{5528AEFB-638D-49AF-B9D4-965154E7D531}.Debug|x86.Build.0 = Debug|Win32
{5528AEFB-638D-49AF-B9D4-965154E7D531}.Release|x64.ActiveCfg = Release|x64
{5528AEFB-638D-49AF-B9D4-965154E7D531}.Release|x64.Build.0 = Release|x64
{5528AEFB-638D-49AF-B9D4-965154E7D531}.Release|x86.ActiveCfg = Release|Win32
{5528AEFB-638D-49AF-B9D4-965154E7D531}.Release|x86.Build.0 = Release|Win32
{691DB635-C272-4B98-897E-0505B970DCA9}.Debug|x64.ActiveCfg = Debug|x64
{691DB635-C272-4B98-897E-0505B970DCA9}.Debug|x64.Build.0 = Debug|x64
{691DB635-C272-4B98-897E-0505B970DCA9}.Debug|x86.ActiveCfg = Debug|Win32
{691DB635-C272-4B98-897E-0505B970DCA9}.Debug|x86.Build.0 = Debug|Win32
{691DB635-C272-4B98-897E-0505B970DCA9}.Release|x64.ActiveCfg = Release|x64
{691DB635-C272-4B98-897E-0505B970DCA9}.Release|x64.Build.0 = Release|x64
{691DB635-C272-4B98-897E-0505B970DCA9}.Release|x86.ActiveCfg = Release|Win32
{BD34DB24-F5DC-4992-A74F-05FAF731ABED}.Debug|x64.ActiveCfg = Debug|Win32
{BD34DB24-F5DC-4992-A74F-05FAF731ABED}.Debug|x86.ActiveCfg = Debug|Win32
{BD34DB24-F5DC-4992-A74F-05FAF731ABED}.Release|x64.ActiveCfg = Release|Win32
{BD34DB24-F5DC-4992-A74F-05FAF731ABED}.Release|x86.ActiveCfg = Release|Win32
{7912F978-B48C-4C5D-8BFD-5D1E22158E47}.Debug|x64.ActiveCfg = Debug|Win32
{7912F978-B48C-4C5D-8BFD-5D1E22158E47}.Debug|x86.ActiveCfg = Debug|Win32
{7912F978-B48C-4C5D-8BFD-5D1E22158E47}.Debug|x86.Build.0 = Debug|Win32
{7912F978-B48C-4C5D-8BFD-5D1E22158E47}.Release|x64.ActiveCfg = Release|Win32
{7912F978-B48C-4C5D-8BFD-5D1E22158E47}.Release|x86.ActiveCfg = Release|Win32
{96E0E646-EE76-444D-9A77-A0CD7F781DEB}.Debug|x64.ActiveCfg = Debug|x64
{96E0E646-EE76-444D-9A77-A0CD7F781DEB}.Debug|x64.Build.0 = Debug|x64
{96E0E646-EE76-444D-9A77-A0CD7F781DEB}.Debug|x86.ActiveCfg = Debug|Win32
{96E0E646-EE76-444D-9A77-A0CD7F781DEB}.Debug|x86.Build.0 = Debug|Win32
{96E0E646-EE76-444D-9A77-A0CD7F781DEB}.Release|x64.ActiveCfg = Release|x64
{96E0E646-EE76-444D-9A77-A0CD7F781DEB}.Release|x64.Build.0 = Release|x64
{96E0E646-EE76-444D-9A77-A0CD7F781DEB}.Release|x86.ActiveCfg = Release|Win32
{D99E2FCD-21A4-4065-949A-31E34E0E69D1}.Debug|x64.ActiveCfg = Debug|x64
{D99E2FCD-21A4-4065-949A-31E34E0E69D1}.Debug|x64.Build.0 = Debug|x64
{D99E2FCD-21A4-4065-949A-31E34E0E69D1}.Debug|x86.ActiveCfg = Debug|Win32
{D99E2FCD-21A4-4065-949A-31E34E0E69D1}.Debug|x86.Build.0 = Debug|Win32
{D99E2FCD-21A4-4065-949A-31E34E0E69D1}.Release|x64.ActiveCfg = Release|x64
{D99E2FCD-21A4-4065-949A-31E34E0E69D1}.Release|x64.Build.0 = Release|x64
{D99E2FCD-21A4-4065-949A-31E34E0E69D1}.Release|x86.ActiveCfg = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {8AF3826E-406A-4F1C-BA80-B4D7FD4B52E1}
EndGlobalSection
GlobalSection(Performance) = preSolution
HasPerformanceSessions = true
EndGlobalSection
EndGlobal

Binary file not shown.

After

Width:  |  Height:  |  Size: 95 KiB

Binary file not shown.

View File

@@ -0,0 +1,189 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{5528AEFB-638D-49AF-B9D4-965154E7D531}</ProjectGuid>
<Keyword>Win32Proj</Keyword>
<RootNamespace>panda</RootNamespace>
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="Shared">
<Import Project="..\panda_shared\panda_shared.vcxitems" Label="Shared" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<LinkIncremental>true</LinkIncremental>
<OutDir>$(SolutionDir)$(Configuration)_$(PlatformShortName)\</OutDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<LinkIncremental>true</LinkIncremental>
<OutDir>$(SolutionDir)$(Configuration)_$(PlatformShortName)\</OutDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LinkIncremental>false</LinkIncremental>
<OutDir>$(SolutionDir)$(Configuration)_$(PlatformShortName)\</OutDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<LinkIncremental>false</LinkIncremental>
<OutDir>$(SolutionDir)$(Configuration)_$(PlatformShortName)\</OutDir>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<PrecompiledHeader>Use</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;_USRDLL;PANDA_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<SDLCheck>true</SDLCheck>
<TreatWarningAsError>false</TreatWarningAsError>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);winusb.lib;setupapi.lib</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<PrecompiledHeader>Use</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>_DEBUG;_WINDOWS;_USRDLL;PANDA_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<SDLCheck>true</SDLCheck>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);winusb.lib;setupapi.lib</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<PrecompiledHeader>Use</PrecompiledHeader>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;PANDA_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<SDLCheck>true</SDLCheck>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);winusb.lib;setupapi.lib</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<PrecompiledHeader>Use</PrecompiledHeader>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>NDEBUG;_WINDOWS;_USRDLL;PANDA_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<SDLCheck>true</SDLCheck>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);winusb.lib;setupapi.lib</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClInclude Include="resource.h" />
<ClInclude Include="stdafx.h" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="dllmain.cpp">
<CompileAsManaged Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">false</CompileAsManaged>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
</PrecompiledHeader>
<CompileAsManaged Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">false</CompileAsManaged>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
</PrecompiledHeader>
<CompileAsManaged Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</CompileAsManaged>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
</PrecompiledHeader>
<CompileAsManaged Condition="'$(Configuration)|$(Platform)'=='Release|x64'">false</CompileAsManaged>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
</PrecompiledHeader>
</ClCompile>
<ClCompile Include="stdafx.cpp">
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Create</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Create</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Create</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Create</PrecompiledHeader>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="panda.rc" />
</ItemGroup>
<ItemGroup>
<Image Include="panda.ico" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

View File

@@ -0,0 +1,43 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="Source Files">
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
</Filter>
<Filter Include="Header Files">
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
<Extensions>h;hh;hpp;hxx;hm;inl;inc;xsd</Extensions>
</Filter>
<Filter Include="Resource Files">
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
</Filter>
</ItemGroup>
<ItemGroup>
<ClInclude Include="stdafx.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="resource.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="stdafx.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="dllmain.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="panda.rc">
<Filter>Resource Files</Filter>
</ResourceCompile>
</ItemGroup>
<ItemGroup>
<Image Include="panda.ico">
<Filter>Resource Files</Filter>
</Image>
</ItemGroup>
</Project>

Binary file not shown.

View File

@@ -0,0 +1,19 @@
// stdafx.h : include file for standard system include files,
// or project specific include files that are used frequently, but
// are changed infrequently
//
#pragma once
#include "targetver.h"
#ifndef WIN32_LEAN_AND_MEAN
#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
#endif
// Windows Header Files:
#include <windows.h>
#include <tchar.h>
#include <strsafe.h>
#include <winusb.h>
#include <usb.h>

View File

@@ -0,0 +1,55 @@
// Loader4.h
// (c) 2005 National Control Systems, Inc.
// Portions (c) 2004 Drew Technologies, Inc.
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or any later version.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to:
// the Free Software Foundation, Inc.
// 51 Franklin Street, Fifth Floor
// Boston, MA 02110-1301, USA
// National Control Systems, Inc.
// 10737 Hamburg Rd
// Hamburg, MI 48139
// 810-231-2901
// Drew Technologies, Inc.
// 7012 E.M -36, Suite 3B
// Whitmore Lake, MI 48189
// 810-231-3171
#include "pandaJ2534DLL/J2534_v0404.h"
//Other Functions
long WINAPI LoadJ2534Dll(char *);
long WINAPI UnloadJ2534Dll();
// NCS Returns of any functions not found
#define ERR_NO_PTOPEN 0x0001
#define ERR_NO_PTCLOSE 0x0002
#define ERR_NO_PTCONNECT 0x0004
#define ERR_NO_PTDISCONNECT 0x0008
#define ERR_NO_PTREADMSGS 0x0010
#define ERR_NO_PTWRITEMSGS 0x0020
#define ERR_NO_PTSTARTPERIODICMSG 0x0040
#define ERR_NO_PTSTOPPERIODICMSG 0x0080
#define ERR_NO_PTSTARTMSGFILTER 0x0100
#define ERR_NO_PTSTOPMSGFILTER 0x0200
#define ERR_NO_PTSETPROGRAMMINGVOLTAGE 0x0400
#define ERR_NO_PTREADVERSION 0x0800
#define ERR_NO_PTGETLASTERROR 0x1000
#define ERR_NO_PTIOCTL 0x2000
#define ERR_NO_FUNCTIONS 0x3fff
#define ERR_NO_DLL -1
#define ERR_WRONG_DLL_VER -2
#define ERR_FUNC_MISSING -3

View File

@@ -0,0 +1,48 @@
#pragma once
#include "stdafx.h"
#include "pandaJ2534DLL/J2534_v0404.h"
#include "panda_shared/panda.h"
using namespace Microsoft::VisualStudio::CppUnitTestFramework;
extern void write_ioctl(unsigned int chanid, unsigned int param, unsigned int val, const __LineInfo* pLineInfo = NULL);
extern std::vector<panda::PANDA_CAN_MSG> panda_recv_loop_loose(std::unique_ptr<panda::Panda>& p, unsigned int min_num, unsigned long timeout_ms = 100);
extern std::vector<panda::PANDA_CAN_MSG> panda_recv_loop(std::unique_ptr<panda::Panda>& p, unsigned int num_expected, unsigned long timeout_ms = 100);
extern void check_panda_can_msg(panda::PANDA_CAN_MSG& msgin, uint8_t bus, unsigned long addr, bool addr_29b,
bool is_receipt, std::string dat, const __LineInfo* pLineInfo = NULL);
extern unsigned long J2534_start_periodic_msg_checked(unsigned long chanid, unsigned long ProtocolID, unsigned long TxFlags, unsigned long DataSize,
unsigned long ExtraDataIndex, const char * Data, unsigned long TimeInterval, const __LineInfo * pLineInfo);
extern unsigned long J2534_start_periodic_msg(unsigned long chanid, unsigned long ProtocolID, unsigned long TxFlags, unsigned long DataSize,
unsigned long ExtraDataIndex, const char* Data, unsigned long TimeInterval, unsigned long* msgID, const __LineInfo* pLineInfo = NULL);
extern void J2534_send_msg_checked(unsigned long chanid, unsigned long ProtocolID, unsigned long RxStatus, unsigned long TxFlags,
unsigned long Timestamp, unsigned long DataSize, unsigned long ExtraDataIndex, const char* Data, const __LineInfo* pLineInfo = NULL);
extern long J2534_send_msg(unsigned long chanid, unsigned long ProtocolID, unsigned long RxStatus, unsigned long TxFlags,
unsigned long Timestamp, unsigned long DataSize, unsigned long ExtraDataIndex, const char* Data);
extern std::vector<PASSTHRU_MSG> j2534_recv_loop_loose(unsigned int chanid, unsigned int min_num, unsigned long timeout_ms = 100);
extern std::vector<PASSTHRU_MSG> j2534_recv_loop(unsigned int chanid, unsigned int num_expected, unsigned long timeout_ms = 100);
extern void check_J2534_can_msg(PASSTHRU_MSG& msgin, unsigned long ProtocolID, unsigned long RxStatus, unsigned long TxFlags,
unsigned long DataSize, unsigned long ExtraDataIndex, const char* Data, const __LineInfo* pLineInfo = NULL);
extern unsigned long J2534_set_PASS_filter(unsigned long chanid, unsigned long ProtocolID, unsigned long tx,
unsigned long len, char* mask, char* pattern, const __LineInfo* pLineInfo = NULL);
extern unsigned long J2534_set_BLOCK_filter(unsigned long chanid, unsigned long ProtocolID, unsigned long tx,
unsigned long len, char* mask, char* pattern, const __LineInfo* pLineInfo = NULL);
extern unsigned long J2534_set_flowctrl_filter(unsigned long chanid, unsigned long tx,
unsigned long len, char* mask, char* pattern, char* flow, const __LineInfo* pLineInfo = NULL);
extern std::unique_ptr<panda::Panda> getPanda(unsigned long kbaud = 500, BOOL loopback = FALSE);
extern std::vector<panda::PANDA_CAN_MSG> checked_panda_send(std::unique_ptr<panda::Panda>& p, uint32_t addr, bool is_29b,
char* msg, uint8_t len, unsigned int num_expected=0, const __LineInfo* pLineInfo = NULL, unsigned long timeout_ms = 100);

View File

@@ -0,0 +1,20 @@
#pragma once
#include <chrono>
//Copied from https://stackoverflow.com/a/31488113
class Timer
{
using clock = std::chrono::steady_clock;
using time_point_type = std::chrono::time_point < clock, std::chrono::milliseconds >;
public:
Timer();
// gets the time elapsed from construction.
unsigned long long /*milliseconds*/ getTimePassed();
void reset();
private:
time_point_type start;
};

View File

@@ -0,0 +1,122 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{7912F978-B48C-4C5D-8BFD-5D1E22158E47}</ProjectGuid>
<Keyword>Win32Proj</Keyword>
<RootNamespace>pandaJ2534DLLTest</RootNamespace>
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
<ProjectName>Tests</ProjectName>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
<UseOfMfc>false</UseOfMfc>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
<UseOfMfc>false</UseOfMfc>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="Shared">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<LinkIncremental>true</LinkIncremental>
<OutDir>$(SolutionDir)$(Configuration)_$(PlatformShortName)\</OutDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LinkIncremental>true</LinkIncremental>
<OutDir>$(SolutionDir)$(Configuration)_$(PlatformShortName)\</OutDir>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<PrecompiledHeader>Use</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<AdditionalIncludeDirectories>$(VCInstallDir)UnitTest\include;%(AdditionalIncludeDirectories);$(SolutionDir)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<UseFullPaths>true</UseFullPaths>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<AdditionalLibraryDirectories>$(VCInstallDir)UnitTest\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);$(OutDir)panda.lib</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<PrecompiledHeader>Use</PrecompiledHeader>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<AdditionalIncludeDirectories>$(VCInstallDir)UnitTest\include;%(AdditionalIncludeDirectories);$(SolutionDir)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<UseFullPaths>true</UseFullPaths>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<AdditionalLibraryDirectories>$(VCInstallDir)UnitTest\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);$(OutDir)panda.lib</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClInclude Include="..\pandaJ2534DLL\J2534_v0404.h" />
<ClInclude Include="..\panda\panda.h" />
<ClInclude Include="Loader4.h" />
<ClInclude Include="stdafx.h" />
<ClInclude Include="targetver.h" />
<ClInclude Include="TestHelpers.h" />
<ClInclude Include="Timer.h" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="ECUsim_tests.cpp" />
<ClCompile Include="Loader4.cpp" />
<ClCompile Include="panda_tests.cpp" />
<ClCompile Include="stdafx.cpp">
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Create</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Create</PrecompiledHeader>
</ClCompile>
<ClCompile Include="j2534_tests.cpp" />
<ClCompile Include="TestHelpers.cpp" />
<ClCompile Include="Timer.cpp" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\ECUsim DLL\ECUsim DLL.vcxproj">
<Project>{96e0e646-ee76-444d-9a77-a0cd7f781deb}</Project>
</ProjectReference>
<ProjectReference Include="..\pandaJ2534DLL\pandaJ2534DLL.vcxproj">
<Project>{a2bb18a5-f26b-48d6-bbb5-b83d64473c77}</Project>
</ProjectReference>
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

View File

@@ -0,0 +1,63 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="Source Files">
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
</Filter>
<Filter Include="Header Files">
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
<Extensions>h;hh;hpp;hxx;hm;inl;inc;xsd</Extensions>
</Filter>
<Filter Include="Resource Files">
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
</Filter>
</ItemGroup>
<ItemGroup>
<ClInclude Include="stdafx.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="targetver.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="Loader4.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\pandaJ2534DLL\J2534_v0404.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="Timer.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\panda\panda.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="TestHelpers.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="stdafx.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="j2534_tests.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="Loader4.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="Timer.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="TestHelpers.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="ECUsim_tests.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="panda_tests.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
</Project>

View File

@@ -0,0 +1,14 @@
#pragma once
#include "targetver.h"
#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
// Windows Header Files:
#include <windows.h>
#include <tchar.h>
// Headers for CppUnitTest
#include "CppUnitTest.h"
#include <iomanip> //Used for formatting in TestHelpers.cpp
#include <string>
#include <array>

View File

@@ -0,0 +1,8 @@
#pragma once
// Including SDKDDKVer.h defines the highest available Windows platform.
// If you wish to build your application for a previous Windows platform, include WinSDKVer.h and
// set the _WIN32_WINNT macro to the platform you wish to support before including SDKDDKVer.h.
#include <SDKDDKVer.h>

View File

@@ -0,0 +1,57 @@
#pragma once
#include <memory>
#include "J2534Frame.h"
class J2534Connection;
/**
An Action represents a unit of work that can be scheduled for execution at a later time.
Actions are not guaranteed to be run at their specified time, but a best effort is made.
An Action will never execute early, but can execute later depending on what is in the
queus.
Many different operations are based on this base class. Instead of making a thread,
consider if the work can be offloaded to the Task Queue.
*/
class Action
{
public:
Action(
std::weak_ptr<J2534Connection> connection,
std::chrono::microseconds delay
) : connection(connection), delay(delay) { };
Action(
std::weak_ptr<J2534Connection> connection
) : connection(connection), delay(std::chrono::microseconds(0)) { };
//The function called by the task runner when this action is to be invoked.
virtual void execute() = 0;
//Reschedule this Action for now().
void scheduleImmediate() {
expire = std::chrono::steady_clock::now();
}
//Reschedule this Action relative to its last expiration time.
void scheduleDelay() {
expire += this->delay;
}
//Reschedule this action {delay} after now().
void scheduleImmediateDelay() {
expire = std::chrono::steady_clock::now() + this->delay;
}
//Reschedule this Action based on a specific base time.
void schedule(std::chrono::time_point<std::chrono::steady_clock> starttine, BOOL adddelayed) {
this->expire = starttine;
if (adddelayed)
expire += this->delay;
}
std::weak_ptr<J2534Connection> connection;
std::chrono::microseconds delay;
//The timestamp at which point this Action is ready to be executed.
std::chrono::time_point<std::chrono::steady_clock> expire;
};

View File

@@ -0,0 +1,143 @@
#pragma once
#include "panda_shared/panda.h"
#include "J2534_v0404.h"
#include "synchronize.h"
#include "J2534Frame.h"
#include "PandaJ2534Device.h"
#include "J2534MessageFilter.h"
#include "MessagePeriodic.h"
class J2534Frame;
class Action;
class PandaJ2534Device;
class J2534MessageFilter;
#define check_bmask(num, mask)(((num) & mask) == mask)
/**
Class representing a generic J2534 Connection created by PassThruConnect,
and is associated with a channelID given to the J2534 API user.
Subclasses implement specific J2534 supported protocols.
*/
class J2534Connection : public std::enable_shared_from_this<J2534Connection> {
friend class PandaJ2534Device;
public:
J2534Connection(
std::shared_ptr<PandaJ2534Device> panda_dev,
unsigned long ProtocolID,
unsigned long Flags,
unsigned long BaudRate
);
virtual ~J2534Connection() {};
//J2534 API functions
virtual long PassThruReadMsgs(PASSTHRU_MSG *pMsg, unsigned long *pNumMsgs, unsigned long Timeout);
long PassThruWriteMsgs(PASSTHRU_MSG *pMsg, unsigned long *pNumMsgs, unsigned long Timeout);
virtual long PassThruStartPeriodicMsg(PASSTHRU_MSG *pMsg, unsigned long *pMsgID, unsigned long TimeInterval);
virtual long PassThruStopPeriodicMsg(unsigned long MsgID);
virtual long PassThruStartMsgFilter(unsigned long FilterType, PASSTHRU_MSG *pMaskMsg, PASSTHRU_MSG *pPatternMsg,
PASSTHRU_MSG *pFlowControlMsg, unsigned long *pFilterID);
virtual long PassThruStopMsgFilter(unsigned long FilterID);
virtual long PassThruIoctl(unsigned long IoctlID, void *pInput, void *pOutput);
//Functions for parsing messages to be send with PassThruWriteMsgs.
virtual unsigned long validateTxMsg(PASSTHRU_MSG* msg);
virtual std::shared_ptr<MessageTx> parseMessageTx(PASSTHRU_MSG& msg) { return nullptr; };
//IOCTL functions
virtual long init5b(SBYTE_ARRAY* pInput, SBYTE_ARRAY* pOutput);
virtual long initFast(PASSTHRU_MSG* pInput, PASSTHRU_MSG* pOutput);
long clearTXBuff();
long clearRXBuff();
long clearPeriodicMsgs();
long clearMsgFilters();
virtual void setBaud(unsigned long baud);
virtual void setParity(unsigned long parity);
unsigned long getBaud() {
return this->BaudRate;
}
unsigned long getProtocol() {
return this->ProtocolID;
};
virtual bool isProtoCan() {
return FALSE;
}
//Port is used in a protocol specific way to differentiate tranceivers.
unsigned long getPort() {
return this->port;
}
virtual void processIOCTLSetConfig(unsigned long Parameter, unsigned long Value);
virtual unsigned long processIOCTLGetConfig(unsigned long Parameter);
//Called when the passthru device has received a message for this connection
//Loopback messages are processed separately.
virtual void processMessage(const J2534Frame& msg);
//Limitations on message size. Override in every subclass.
virtual unsigned long getMinMsgLen() {
return 1;
}
virtual unsigned long getMaxMsgLen() {
return 4128;
}
virtual unsigned long getMaxMsgSingleFrameLen() {
return 12;
}
//Add an Action to the Task Queue for future processing.
//The task should be set its expire time before being submitted.
void schedultMsgTx(std::shared_ptr<Action> msgout);
void rescheduleExistingTxMsgs();
std::shared_ptr<PandaJ2534Device> getPandaDev() {
if (auto panda_dev_sp = this->panda_dev.lock())
return panda_dev_sp;
return nullptr;
}
//Add a message to the queue read by PassThruReadMsgs().
void addMsgToRxQueue(const J2534Frame& frame) {
synchronized(messageRxBuff_mutex) {
messageRxBuff.push(frame);
}
}
bool loopback = FALSE;
protected:
unsigned long ProtocolID;
unsigned long Flags;
unsigned long BaudRate;
unsigned long Parity;
unsigned long port;
std::weak_ptr<PandaJ2534Device> panda_dev;
Mutex messageRxBuff_mutex;
std::queue<J2534Frame> messageRxBuff;
std::array<std::shared_ptr<J2534MessageFilter>, 10> filters;
std::queue<std::shared_ptr<Action>> txbuff;
std::array<std::shared_ptr<MessagePeriodic>, 10> periodicMessages;
private:
Mutex staged_writes_lock;
};

View File

@@ -0,0 +1,43 @@
#pragma once
#include "J2534Connection.h"
#include "panda_shared/panda.h"
#define val_is_29bit(num) check_bmask(num, CAN_29BIT_ID)
class J2534Connection_CAN : public J2534Connection {
public:
J2534Connection_CAN(
std::shared_ptr<PandaJ2534Device> panda_dev,
unsigned long ProtocolID,
unsigned long Flags,
unsigned long BaudRate
);
virtual unsigned long validateTxMsg(PASSTHRU_MSG* msg);
virtual std::shared_ptr<MessageTx> parseMessageTx(PASSTHRU_MSG& pMsg);
virtual void setBaud(unsigned long baud);
virtual unsigned long getMinMsgLen() {
return 4;
}
virtual unsigned long getMaxMsgLen() {
return 12;
}
virtual unsigned long getMaxMsgSingleFrameLen() {
return 12;
}
virtual bool isProtoCan() {
return TRUE;
}
bool _is_29bit() {
return (this->Flags & CAN_29BIT_ID) == CAN_29BIT_ID;
}
};

View File

@@ -0,0 +1,39 @@
#pragma once
#include "J2534Connection.h"
#include "panda_shared/panda.h"
class J2534Connection_ISO14230 : public J2534Connection {
public:
J2534Connection_ISO14230(
std::shared_ptr<PandaJ2534Device> panda_dev,
unsigned long ProtocolID,
unsigned long Flags,
unsigned long BaudRate
);
virtual unsigned long validateTxMsg(PASSTHRU_MSG* msg);
virtual std::shared_ptr<MessageTx> parseMessageTx(PASSTHRU_MSG& pMsg);
virtual void setBaud(unsigned long baud);
virtual void setParity(unsigned long Parity);
virtual unsigned long getMinMsgLen() {
return 2;
}
virtual unsigned long getMaxMsgLen() {
return KLINE_MSG_MAX_LEN;
}
virtual unsigned long getMaxMsgSingleFrameLen() {
return KLINE_MSG_MAX_LEN;
}
virtual bool isProtoCan() {
return FALSE;
}
virtual void processMessage(const J2534Frame& msg);
};

View File

@@ -0,0 +1,65 @@
#pragma once
#include <string>
#include "J2534Connection.h"
#include "J2534Connection_CAN.h"
#include "MessageTx_ISO15765.h"
#include "MessageRx.h"
class MessageTx_ISO15765;
typedef struct {
std::string dispatched_msg;
std::string remaining_payload;
} PRESTAGED_WRITE;
class J2534Connection_ISO15765 : public J2534Connection {
public:
J2534Connection_ISO15765(
std::shared_ptr<PandaJ2534Device> panda_dev,
unsigned long ProtocolID,
unsigned long Flags,
unsigned long BaudRate
);
virtual long PassThruStartMsgFilter(unsigned long FilterType, PASSTHRU_MSG * pMaskMsg, PASSTHRU_MSG * pPatternMsg, PASSTHRU_MSG * pFlowControlMsg, unsigned long * pFilterID);
int get_matching_out_fc_filter_id(const std::string & msgdata, unsigned long flags, unsigned long flagmask);
int get_matching_in_fc_filter_id(const J2534Frame& msg, unsigned long flagmask);
virtual unsigned long validateTxMsg(PASSTHRU_MSG* msg);
virtual std::shared_ptr<MessageTx> parseMessageTx(PASSTHRU_MSG& msg);
virtual void processMessage(const J2534Frame& msg);
virtual void setBaud(unsigned long baud);
virtual void processIOCTLSetConfig(unsigned long Parameter, unsigned long Value);
virtual unsigned long processIOCTLGetConfig(unsigned long Parameter);
virtual unsigned long getMinMsgLen() {
return 4;
}
virtual unsigned long getMaxMsgLen() {
return 4099;
};
virtual unsigned long getMaxMsgSingleFrameLen() {
return 11;
}
virtual bool _is_29bit() {
return (this->Flags & CAN_29BIT_ID) == CAN_29BIT_ID;
}
virtual bool isProtoCan() {
return TRUE;
}
private:
std::array<std::shared_ptr<MessageRx>, 10> rxConversations;
unsigned int wftMax;
};

View File

@@ -0,0 +1,58 @@
#pragma once
#include "J2534_v0404.h"
#include "panda_shared/panda.h"
/*A move convenient container for J2534 Messages than the static buffer provided by default.*/
class J2534Frame {
public:
J2534Frame(unsigned long ProtocolID, unsigned long RxStatus=0, unsigned long TxFlags=0, unsigned long Timestamp=0) :
ProtocolID(ProtocolID), RxStatus(RxStatus), TxFlags(TxFlags), Timestamp(Timestamp), ExtraDataIndex(0), Data("") { };
J2534Frame(const panda::PANDA_CAN_MSG& msg_in) {
ProtocolID = CAN;
ExtraDataIndex = msg_in.len + 4;
Data.reserve(msg_in.len + 4);
Data += msg_in.addr >> 24;
Data += (msg_in.addr >> 16) & 0xFF;
Data += (msg_in.addr >> 8) & 0xFF;
Data += msg_in.addr & 0xFF;
Data += std::string((char*)&msg_in.dat, msg_in.len);
Timestamp = msg_in.recv_time;
TxFlags = 0;
RxStatus = (msg_in.addr_29b ? CAN_29BIT_ID : 0) |
(msg_in.is_receipt ? TX_MSG_TYPE : 0);
}
J2534Frame(unsigned long protocol, const panda::PANDA_KLINE_MSG& msg_in) {
ProtocolID = protocol;
ExtraDataIndex = msg_in.data.size() - (msg_in.valid ? 1 : 0);
Data = msg_in.data;
Timestamp = 0;
TxFlags = 0;
RxStatus = 0;
}
J2534Frame(const PASSTHRU_MSG& msg) {
this->ProtocolID = msg.ProtocolID;
this->RxStatus = msg.RxStatus;
this->TxFlags = msg.TxFlags;
this->Timestamp = msg.Timestamp;
this->ExtraDataIndex = msg.ExtraDataIndex;
this->Data = std::string((const char*)msg.Data, msg.DataSize);
}
J2534Frame() {
this->ProtocolID = 0;
this->RxStatus = 0;
this->TxFlags = 0;
this->Timestamp = 0;
this->ExtraDataIndex = 0;
}
unsigned long ProtocolID;
unsigned long RxStatus;
unsigned long TxFlags;
unsigned long Timestamp;
unsigned long ExtraDataIndex;
std::string Data;
};

View File

@@ -0,0 +1,47 @@
#pragma once
#include "J2534_v0404.h"
#include "J2534Connection.h"
#include "J2534Frame.h"
typedef enum {
FILTER_RESULT_BLOCK,
FILTER_RESULT_NEUTRAL,
FILTER_RESULT_PASS,
FILTER_RESULT_NOMATCH = FILTER_RESULT_BLOCK,
FILTER_RESULT_MATCH = FILTER_RESULT_PASS,
} FILTER_RESULT;
//Forward declare
class J2534Connection;
/* Represents a J2534 Message Filter created by PassThruStartMsgFilter.
J2534 uses filters to sort out messages in a simple and sane way. Except for
flow control filters. J2534 v04.04 uses filters to manage 'conversations' in
protocols that support flow control like ISO15765. The whole solution is a
hack, and J2534 v05.00 greatly simplifies this concept. But we are using
v04.04 so, here we are.
*/
class J2534MessageFilter {
public:
J2534MessageFilter(
J2534Connection *const conn,
unsigned int filtertype,
PASSTHRU_MSG *pMaskMsg,
PASSTHRU_MSG *pPatternMsg,
PASSTHRU_MSG *pFlowControlMsg
);
bool J2534MessageFilter::operator ==(const J2534MessageFilter &b) const;
FILTER_RESULT check(const J2534Frame& msg);
std::string get_flowctrl();
unsigned long flags;
J2534Connection *const conn;
private:
unsigned int filtertype;
std::string maskMsg;
std::string patternMsg;
std::string flowCtrlMsg;
};

View File

@@ -0,0 +1,428 @@
//
// Copyright (c) 2015-2016 DashLogic, Inc.
// All Rights Reserved.
//
// http://www.dashlogic.com
// sales@dashlogic.com
//
// Redistribution and use in source and binary forms, with or without
// modification, including use for commercial purposes, are permitted
// provided that the following conditions are met:
//
// 1. Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
//
// 2. Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in
// the documentation and/or other materials provided with the
// distribution.
//
// 3. Neither the name of the copyright holder nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// 4. Redistributions of any form whatsoever must retain the following
// acknowledgment: 'This product includes software developed by
// "DashLogic, Inc." (http://www.dashlogic.com/).'
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
// TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
//
// Formatting:
// Indents: Use tabs only (1 tab per indent)
// Tab Size: 4 spaces
//
// File Revision:
// $Rev: 5216 $
// $Date: 2016-03-15 09:32:34 -0600 (Tue, 15 Mar 2016) $
//
#pragma once
#ifdef PANDAJ2534DLL_EXPORTS
#define PANDAJ2534DLL_API extern "C" __declspec(dllexport)
#else
#define PANDAJ2534DLL_API
//__declspec(dllimport)
#endif
//
// Platform-specific Defines:
//
// PTAPI: Define this yourself if you want a specific calling
// convention or other modifiers on the Pass-Thru API
// functions. Typically, on Windows, PTAPI will be defined
// as WINAPI, which enables the __stdcall convention.
//
#define PTAPI __stdcall //WINAPI
//
// J2534-1 v04.04 ProtocolID Values
//
#define J1850VPW 0x01
#define J1850PWM 0x02
#define ISO9141 0x03
#define ISO14230 0x04
#define CAN 0x05
#define ISO15765 0x06
#define SCI_A_ENGINE 0x07
#define SCI_A_TRANS 0x08
#define SCI_B_ENGINE 0x09
#define SCI_B_TRANS 0x0A
//
// J2534-2 ProtocolID Values
//
#define J1850VPW_PS 0x00008000
#define J1850PWM_PS 0x00008001
#define ISO9141_PS 0x00008002
#define ISO14230_PS 0x00008003
#define CAN_PS 0x00008004
#define ISO15765_PS 0x00008005
#define J2610_PS 0x00008006
#define SW_ISO15765_PS 0x00008007
#define SW_CAN_PS 0x00008008
#define GM_UART_PS 0x00008009
#define CAN_CH1 0x00009000
#define CAN_CH2 (CAN_CH1 + 1)
#define CAN_CH128 (CAN_CH1 + 127)
#define J1850VPW_CH1 0x00009080
#define J1850VPW_CH2 (J1850VPW_CH1 + 1)
#define J1850VPW_CH128 (J1850VPW_CH1 + 127)
#define J1850PWM_CH1 0x00009160
#define J1850PWM_CH2 (J1850PWM_CH1 + 1)
#define J1850PWM_CH128 (J1850PWM_CH1 + 127)
#define ISO9141_CH1 0x00009240
#define ISO9141_CH2 (ISO9141_CH1 + 1)
#define ISO9141_CH128 (ISO9141_CH1 + 127)
#define ISO14230_CH1 0x00009320
#define ISO14230_CH2 (ISO14230_CH1 + 1)
#define ISO14230_CH128 (ISO14230_CH1 + 127)
#define ISO15765_CH1 0x00009400
#define ISO15765_CH2 (ISO15765_CH1 + 1)
#define ISO15765_CH128 (ISO15765_CH1 + 127)
#define SW_CAN_CAN_CH1 0x00009480
#define SW_CAN_CAN_CH2 (SW_CAN_CAN_CH1 + 1)
#define SW_CAN_CAN_CH128 (SW_CAN_CAN_CH1 + 127)
#define SW_CAN_ISO15765_CH1 0x00009560
#define SW_CAN_ISO15765_CH2 (SW_CAN_ISO15765_CH1 + 1)
#define SW_CAN_ISO15765_CH128 (SW_CAN_ISO15765_CH1 + 127)
#define J2610_CH1 0x00009640
#define J2610_CH2 (J2610_CH1 + 1)
#define J2610_CH128 (J2610_CH1 + 127)
#define ANALOG_IN_CH1 0x0000C000
#define ANALOG_IN_CH2 0x0000C001
#define ANALOG_IN_CH32 0x0000C01F
//
// J2534-1 v04.04 Error Values
//
#define STATUS_NOERROR 0x00 // Function call successful.
#define ERR_NOT_SUPPORTED 0x01 // Device cannot support requested functionality mandated in J2534. Device is not fully SAE J2534 compliant.
#define ERR_INVALID_CHANNEL_ID 0x02 // Invalid ChannelID value.
#define ERR_INVALID_PROTOCOL_ID 0x03 // Invalid or unsupported ProtocolID, or there is a resource conflict (i.e. trying to connect to multiple mutually exclusive protocols such as J1850PWM and J1850VPW, or CAN and SCI, etc.).
#define ERR_NULL_PARAMETER 0x04 // NULL pointer supplied where a valid pointer is required.
#define ERR_INVALID_IOCTL_VALUE 0x05 // Invalid value for Ioctl parameter.
#define ERR_INVALID_FLAGS 0x06 // Invalid flag values.
#define ERR_FAILED 0x07 // Undefined error, use PassThruGetLastError() for text description.
#define ERR_DEVICE_NOT_CONNECTED 0x08 // Unable to communicate with device.
#define ERR_TIMEOUT 0x09 // Read or write timeout:
// PassThruReadMsgs() - No message available to read or could not read the specified number of messages. The actual number of messages read is placed in <NumMsgs>.
// PassThruWriteMsgs() - Device could not write the specified number of messages. The actual number of messages sent on the vehicle network is placed in <NumMsgs>.
#define ERR_INVALID_MSG 0x0A // Invalid message structure pointed to by pMsg.
#define ERR_INVALID_TIME_INTERVAL 0x0B // Invalid TimeInterval value.
#define ERR_EXCEEDED_LIMIT 0x0C // Exceeded maximum number of message IDs or allocated space.
#define ERR_INVALID_MSG_ID 0x0D // Invalid MsgID value.
#define ERR_DEVICE_IN_USE 0x0E // Device is currently open.
#define ERR_INVALID_IOCTL_ID 0x0F // Invalid IoctlID value.
#define ERR_BUFFER_EMPTY 0x10 // Protocol message buffer empty, no messages available to read.
#define ERR_BUFFER_FULL 0x11 // Protocol message buffer full. All the messages specified may not have been transmitted.
#define ERR_BUFFER_OVERFLOW 0x12 // Indicates a buffer overflow occurred and messages were lost.
#define ERR_PIN_INVALID 0x13 // Invalid pin number, pin number already in use, or voltage already applied to a different pin.
#define ERR_CHANNEL_IN_USE 0x14 // Channel number is currently connected.
#define ERR_MSG_PROTOCOL_ID 0x15 // Protocol type in the message does not match the protocol associated with the Channel ID
#define ERR_INVALID_FILTER_ID 0x16 // Invalid Filter ID value.
#define ERR_NO_FLOW_CONTROL 0x17 // No flow control filter set or matched (for ProtocolID ISO15765 only).
#define ERR_NOT_UNIQUE 0x18 // A CAN ID in pPatternMsg or pFlowControlMsg matches either ID in an existing FLOW_CONTROL_FILTER
#define ERR_INVALID_BAUDRATE 0x19 // The desired baud rate cannot be achieved within the tolerance specified in SAE J2534-1 Section 6.5
#define ERR_INVALID_DEVICE_ID 0x1A // Device ID invalid.
//
// J2534-1 v04.04 Connect Flags
//
#define CAN_29BIT_ID 0x0100
#define ISO9141_NO_CHECKSUM 0x0200
#define CAN_ID_BOTH 0x0800
#define ISO9141_K_LINE_ONLY 0x1000
//
// J2534-1 v04.04 Filter Type Values
//
#define PASS_FILTER 0x00000001
#define BLOCK_FILTER 0x00000002
#define FLOW_CONTROL_FILTER 0x00000003
//
// J2534-1 v04.04 Programming Voltage Pin Numbers
//
#define AUXILIARY_OUTPUT_PIN 0
#define SAE_J1962_CONNECTOR_PIN_6 6
#define SAE_J1962_CONNECTOR_PIN_9 9
#define SAE_J1962_CONNECTOR_PIN_11 11
#define SAE_J1962_CONNECTOR_PIN_12 12
#define SAE_J1962_CONNECTOR_PIN_13 13
#define SAE_J1962_CONNECTOR_PIN_14 14
#define SAE_J1962_CONNECTOR_PIN_15 15 // Short to ground only
//
// J2534-1 v04.04 Programming Voltage Values
//
#define SHORT_TO_GROUND 0xFFFFFFFE
#define VOLTAGE_OFF 0xFFFFFFFF
//
// J2534-1 v04.04 API Version Values
//
#define J2534_APIVER_FEBRUARY_2002 "02.02"
#define J2534_APIVER_NOVEMBER_2004 "04.04"
//
// J2534-1 v04.04 IOCTL ID Values
//
#define GET_CONFIG 0x01 // pInput = SCONFIG_LIST, pOutput = NULL
#define SET_CONFIG 0x02 // pInput = SCONFIG_LIST, pOutput = NULL
#define READ_VBATT 0x03 // pInput = NULL, pOutput = unsigned long
#define FIVE_BAUD_INIT 0x04 // pInput = SBYTE_ARRAY, pOutput = SBYTE_ARRAY
#define FAST_INIT 0x05 // pInput = PASSTHRU_MSG, pOutput = PASSTHRU_MSG
#define CLEAR_TX_BUFFER 0x07 // pInput = NULL, pOutput = NULL
#define CLEAR_RX_BUFFER 0x08 // pInput = NULL, pOutput = NULL
#define CLEAR_PERIODIC_MSGS 0x09 // pInput = NULL, pOutput = NULL
#define CLEAR_MSG_FILTERS 0x0A // pInput = NULL, pOutput = NULL
#define CLEAR_FUNCT_MSG_LOOKUP_TABLE 0x0B // pInput = NULL, pOutput = NULL
#define ADD_TO_FUNCT_MSG_LOOKUP_TABLE 0x0C // pInput = SBYTE_ARRAY, pOutput = NULL
#define DELETE_FROM_FUNCT_MSG_LOOKUP_TABLE 0x0D // pInput = SBYTE_ARRAY, pOutput = NULL
#define READ_PROG_VOLTAGE 0x0E // pInput = NULL, pOutput = unsigned long
//
// J2534-2 IOCTL ID Values
//
#define SW_CAN_HS 0x00008000 // pInput = NULL, pOutput = NULL
#define SW_CAN_NS 0x00008001 // pInput = NULL, pOutput = NULL
#define SET_POLL_RESPONSE 0x00008002 // pInput = SBYTE_ARRAY, pOutput = NULL
#define BECOME_MASTER 0x00008003 // pInput = unsigned char, pOutput = NULL
//
// J2534-1 v04.04 Configuration Parameter Values
// Default value is enclosed in square brackets "[" and "]"
//
#define DATA_RATE 0x01 // 5-500000
#define LOOPBACK 0x03 // 0 (OFF), 1 (ON) [0]
#define NODE_ADDRESS 0x04 // J1850PWM: 0x00-0xFF
#define NETWORK_LINE 0x05 // J1850PWM: 0 (BUS_NORMAL), 1 (BUS_PLUS), 2 (BUS_MINUS) [0]
#define P1_MIN 0x06 // ISO9141 or ISO14230: Not used by interface
#define P1_MAX 0x07 // ISO9141 or ISO14230: 0x1-0xFFFF (.5 ms per bit) [40 (20ms)]
#define P2_MIN 0x08 // ISO9141 or ISO14230: Not used by interface
#define P2_MAX 0x09 // ISO9141 or ISO14230: Not used by interface
#define P3_MIN 0x0A // ISO9141 or ISO14230: 0x0-0xFFFF (.5 ms per bit) [110 (55ms)]
#define P3_MAX 0x0B // ISO9141 or ISO14230: Not used by interface
#define P4_MIN 0x0C // ISO9141 or ISO14230: 0x0-0xFFFF (.5 ms per bit) [10 (5ms)]
#define P4_MAX 0x0D // ISO9141 or ISO14230: Not used by interface
#define W0 0x19 // ISO9141: 0x0-0xFFFF (1 ms per bit) [300]
#define W1 0x0E // ISO9141 or ISO14230: 0x0-0xFFFF (1 ms per bit) [300]
#define W2 0x0F // ISO9141 or ISO14230: 0x0-0xFFFF (1 ms per bit) [20]
#define W3 0x10 // ISO9141 or ISO14230: 0x0-0xFFFF (1 ms per bit) [20]
#define W4 0x11 // ISO9141 or ISO14230: 0x0-0xFFFF (1 ms per bit) [50]
#define W5 0x12 // ISO9141 or ISO14230: 0x0-0xFFFF (1 ms per bit) [300]
#define TIDLE 0x13 // ISO9141 or ISO14230: 0x0-0xFFFF (1 ms per bit) [300]
#define TINIL 0x14 // ISO9141 or ISO14230: 0x0-0xFFFF (1 ms per bit) [25]
#define TWUP 0x15 // ISO9141 or ISO14230: 0x0-0xFFFF (1 ms per bit) [50]
#define PARITY 0x16 // ISO9141 or ISO14230: 0 (NO_PARITY), 1 (ODD_PARITY), 2 (EVEN_PARITY) [0]
#define BIT_SAMPLE_POINT 0x17 // CAN: 0-100 (1% per bit) [80]
#define SYNC_JUMP_WIDTH 0x18 // CAN: 0-100 (1% per bit) [15]
#define T1_MAX 0x1A // SCI: 0x0-0xFFFF (1 ms per bit) [20]
#define T2_MAX 0x1B // SCI: 0x0-0xFFFF (1 ms per bit) [100]
#define T3_MAX 0x24 // SCI: 0x0-0xFFFF (1 ms per bit) [50]
#define T4_MAX 0x1C // SCI: 0x0-0xFFFF (1 ms per bit) [20]
#define T5_MAX 0x1D // SCI: 0x0-0xFFFF (1 ms per bit) [100]
#define ISO15765_BS 0x1E // ISO15765: 0x0-0xFF [0]
#define ISO15765_STMIN 0x1F // ISO15765: 0x0-0xFF [0]
#define ISO15765_BS_TX 0x22 // ISO15765: 0x0-0xFF,0xFFFF [0xFFFF]
#define ISO15765_STMIN_TX 0x23 // ISO15765: 0x0-0xFF,0xFFFF [0xFFFF]
#define DATA_BITS 0x20 // ISO9141 or ISO14230: 0 (8 data bits), 1 (7 data bits) [0]
#define FIVE_BAUD_MOD 0x21 // ISO9141 or ISO14230: 0 (ISO 9141-2/14230-4), 1 (Inv KB2), 2 (Inv Addr), 3 (ISO 9141) [0]
#define ISO15765_WFT_MAX 0x25 // ISO15765: 0x0-0xFF [0]
//
// J2534-2 Configuration Parameter Values
// Default value is enclosed in square brackets "[" and "]"
//
#define CAN_MIXED_FORMAT 0x00008000 // See #defines below. [0]
#define J1962_PINS 0x00008001 // 0xPPSS PP: 0x00-0x10 SS: 0x00-0x10 PP!=SS, except 0x0000. Exclude pins 4, 5, and 16. [0]
#define SW_CAN_HS_DATA_RATE 0x00008010 // SWCAN: 5-500000 [83333]
#define SW_CAN_SPEEDCHANGE_ENABLE 0x00008011 // SWCAN: 0 (DISABLE_SPDCHANGE), 1 (ENABLE_SPDCHANGE) [0]
#define SW_CAN_RES_SWITCH 0x00008012 // SWCAN: 0 (DISCONNECT_RESISTOR), 1 (CONNECT_RESISTOR), 2 (AUTO_ RESISTOR) [0]
#define ACTIVE_CHANNELS 0x00008020 // ANALOG: 0-0xFFFFFFFF
#define SAMPLE_RATE 0x00008021 // ANALOG: 0-0xFFFFFFFF [0] (high bit changes meaning from samples/sec to seconds/sample)
#define SAMPLES_PER_READING 0x00008022 // ANALOG: 1-0xFFFFFFFF [1]
#define READINGS_PER_MSG 0x00008023 // ANALOG: 1-0x00000408 (1 - 1032) [1]
#define AVERAGING_METHOD 0x00008024 // ANALOG: 0-0xFFFFFFFF [0]
#define SAMPLE_RESOLUTION 0x00008025 // ANALOG READ-ONLY: 0x1-0x20 (1 - 32)
#define INPUT_RANGE_LOW 0x00008026 // ANALOG READ-ONLY: 0x80000000-0x7FFFFFFF (-2147483648-2147483647)
#define INPUT_RANGE_HIGH 0x00008027 // ANALOG READ-ONLY: 0x80000000-0x7FFFFFFF (-2147483648-2147483647)
//
// J2534-2 Mixed-Mode/Format CAN Definitions
//
#define CAN_MIXED_FORMAT_OFF 0 // Messages will be treated as ISO 15765 ONLY.
#define CAN_MIXED_FORMAT_ON 1 // Messages will be treated as either ISO 15765 or an unformatted CAN frame.
#define CAN_MIXED_FORMAT_ALL_FRAMES 2 // Messages will be treated as ISO 15765, an unformatted CAN frame, or both.
//
// J2534-2 Analog Channel Averaging Method Definitions
//
#define SIMPLE_AVERAGE 0x00000000 // Simple arithmetic mean
#define MAX_LIMIT_AVERAGE 0x00000001 // Choose the biggest value
#define MIN_LIMIT_AVERAGE 0x00000002 // Choose the lowest value
#define MEDIAN_AVERAGE 0x00000003 // Choose arithmetic median
//
// J2534-1 v04.04 RxStatus Definitions
//
#define TX_MSG_TYPE 0x0001
#define START_OF_MESSAGE 0x0002
#define RX_BREAK 0x0004
#define TX_INDICATION 0x0008
#define ISO15765_PADDING_ERROR 0x0010
#define ISO15765_ADDR_TYPE 0x0080
//#define CAN_29BIT_ID 0x0100 // Defined above
//
// J2534-2 RxStatus Definitions
//
#define SW_CAN_HV_RX 0x00010000 // SWCAN Channels Only
#define SW_CAN_HS_RX 0x00020000 // SWCAN Channels Only
#define SW_CAN_NS_RX 0x00040000 // SWCAN Channels Only
#define OVERFLOW_ 0x00010000 // Analog Input Channels Only
//
// J2534-1 v04.04 TxFlags Definitions
//
#define ISO15765_FRAME_PAD 0x0040
//#define ISO15765_ADDR_TYPE 0x0080 // Defined above
//#define CAN_29BIT_ID 0x0100 // Defined above
#define WAIT_P3_MIN_ONLY 0x0200
#define SCI_MODE 0x400000
#define SCI_TX_VOLTAGE 0x800000
//
// J2534-2 TxFlags Definitions
//
#define SW_CAN_HV_TX 0x00000400
//
// J2534-1 v04.04 Structure Definitions
//
typedef struct
{
unsigned long Parameter; // Name of parameter
unsigned long Value; // Value of the parameter
} SCONFIG;
typedef struct
{
unsigned long NumOfParams; // Number of SCONFIG elements
SCONFIG* ConfigPtr; // Array of SCONFIG
} SCONFIG_LIST;
typedef struct
{
unsigned long NumOfBytes; // Number of bytes in the array
unsigned char* BytePtr; // Array of bytes
} SBYTE_ARRAY;
typedef struct
{
unsigned long ProtocolID;
unsigned long RxStatus;
unsigned long TxFlags;
unsigned long Timestamp;
unsigned long DataSize;
unsigned long ExtraDataIndex;
unsigned char Data[4128];
} PASSTHRU_MSG;
//
// J2534-1 v04.04 Function Prototypes
//
PANDAJ2534DLL_API long PTAPI PassThruOpen(void *pName, unsigned long *pDeviceID);
PANDAJ2534DLL_API long PTAPI PassThruClose(unsigned long DeviceID);
PANDAJ2534DLL_API long PTAPI PassThruConnect(unsigned long DeviceID, unsigned long ProtocolID, unsigned long Flags, unsigned long BaudRate, unsigned long *pChannelID);
PANDAJ2534DLL_API long PTAPI PassThruDisconnect(unsigned long ChannelID);
PANDAJ2534DLL_API long PTAPI PassThruReadMsgs(unsigned long ChannelID, PASSTHRU_MSG *pMsg, unsigned long *pNumMsgs, unsigned long Timeout);
PANDAJ2534DLL_API long PTAPI PassThruWriteMsgs(unsigned long ChannelID, PASSTHRU_MSG *pMsg, unsigned long *pNumMsgs, unsigned long Timeout);
PANDAJ2534DLL_API long PTAPI PassThruStartPeriodicMsg(unsigned long ChannelID, PASSTHRU_MSG *pMsg, unsigned long *pMsgID, unsigned long TimeInterval);
PANDAJ2534DLL_API long PTAPI PassThruStopPeriodicMsg(unsigned long ChannelID, unsigned long MsgID);
PANDAJ2534DLL_API long PTAPI PassThruStartMsgFilter(unsigned long ChannelID, unsigned long FilterType, PASSTHRU_MSG *pMaskMsg, PASSTHRU_MSG *pPatternMsg, PASSTHRU_MSG *pFlowControlMsg, unsigned long *pFilterID);
PANDAJ2534DLL_API long PTAPI PassThruStopMsgFilter(unsigned long ChannelID, unsigned long FilterID);
PANDAJ2534DLL_API long PTAPI PassThruSetProgrammingVoltage(unsigned long DeviceID, unsigned long PinNumber, unsigned long Voltage);
PANDAJ2534DLL_API long PTAPI PassThruReadVersion(unsigned long DeviceID, char *pFirmwareVersion, char *pDllVersion, char *pApiVersion);
PANDAJ2534DLL_API long PTAPI PassThruGetLastError(char *pErrorDescription);
PANDAJ2534DLL_API long PTAPI PassThruIoctl(unsigned long ChannelID, unsigned long IoctlID, void *pInput, void *pOutput);
//
// J2534-1 v04.04 Function Typedefs
// These function typedefs allow simpler use of the J2534 API by
// allowing you to do things like this:
// PTCONNECT pPassThruConnectFunc = GetProcAddress(hModule, "PassThruConnect");
// if (pPassThruConnectFunc == NULL)
// return FALSE;
// pPassThruConnectFunc(DeviceID, CAN, CAN_29BIT_ID, 500000, &ChannelID);
//
typedef long (PTAPI *PTOPEN)(void *pName, unsigned long *pDeviceID);
typedef long (PTAPI *PTCLOSE)(unsigned long DeviceID);
typedef long (PTAPI *PTCONNECT)(unsigned long DeviceID, unsigned long ProtocolID, unsigned long Flags, unsigned long BaudRate, unsigned long *pChannelID);
typedef long (PTAPI *PTDISCONNECT)(unsigned long ChannelID);
typedef long (PTAPI *PTREADMSGS)(unsigned long ChannelID, PASSTHRU_MSG *pMsg, unsigned long *pNumMsgs, unsigned long Timeout);
typedef long (PTAPI *PTWRITEMSGS)(unsigned long ChannelID, PASSTHRU_MSG *pMsg, unsigned long *pNumMsgs, unsigned long Timeout);
typedef long (PTAPI *PTSTARTPERIODICMSG)(unsigned long ChannelID, PASSTHRU_MSG *pMsg, unsigned long *pMsgID, unsigned long TimeInterval);
typedef long (PTAPI *PTSTOPPERIODICMSG)(unsigned long ChannelID, unsigned long MsgID);
typedef long (PTAPI *PTSTARTMSGFILTER)(unsigned long ChannelID, unsigned long FilterType, PASSTHRU_MSG *pMaskMsg, PASSTHRU_MSG *pPatternMsg, PASSTHRU_MSG *pFlowControlMsg, unsigned long *pFilterID);
typedef long (PTAPI *PTSTOPMSGFILTER)(unsigned long ChannelID, unsigned long FilterID);
typedef long (PTAPI *PTSETPROGRAMMINGVOLTAGE)(unsigned long DeviceID, unsigned long PinNumber, unsigned long Voltage);
typedef long (PTAPI *PTREADVERSION)(unsigned long DeviceID, char *pFirmwareVersion, char *pDllVersion, char *pApiVersion);
typedef long (PTAPI *PTGETLASTERROR)(char *pErrorDescription);
typedef long (PTAPI *PTIOCTL)(unsigned long ChannelID, unsigned long IoctlID, void *pInput, void *pOutput);

View File

@@ -0,0 +1,33 @@
#pragma once
#include "Action.h"
#include "MessageTx.h"
class J2534Connection;
/* A message that is resent on a given period. Created with calls to PassThruStartPeriodicMessage.
Instead of making each J2534 protocol implementation have to implement periodic message
functionality, this class takes a message to be sent, and passes along the execute call
to the message, then reschedules itself.
*/
class MessagePeriodic : public Action, public std::enable_shared_from_this<Action>
{
public:
MessagePeriodic(
std::chrono::microseconds delay,
std::shared_ptr<MessageTx> msg
);
virtual void execute();
void cancel() {
this->active = FALSE;
}
protected:
std::shared_ptr<MessageTx> msg;
private:
BOOL runyet;
BOOL active;
};

View File

@@ -0,0 +1,61 @@
#pragma once
class MessageRx
{
public:
MessageRx(
unsigned long size,
std::string piece,
unsigned long rxFlags,
std::shared_ptr<J2534MessageFilter> filter
) : expected_size(size & 0xFFF), flags(rxFlags) {
msg.reserve(expected_size);
msg = piece;
next_part = 1;
};
bool rx_add_frame(uint8_t pci_byte, unsigned int max_packet_size, const std::string piece) {
if ((pci_byte & 0x0F) != this->next_part) {
//TODO: Maybe this should instantly fail the transaction.
return TRUE;
}
this->next_part = (this->next_part + 1) % 0x10;
unsigned int payload_len = min(expected_size - msg.size(), max_packet_size);
if (piece.size() < payload_len) {
//A frame was received that could have held more data.
//No examples of this protocol show that happening, so
//it will be assumed that it is grounds to reset rx.
return FALSE;
}
msg += piece.substr(0, payload_len);
return TRUE;
}
unsigned int bytes_remaining() {
return this->expected_size - this->msg.size();
}
bool is_ready() {
return this->msg.size() == this->expected_size;
}
bool flush_result(std::string& final_msg) {
if (this->msg.size() == this->expected_size) {
final_msg = this->msg;
return TRUE;
}
return FALSE;
}
uint8_t getNextConsecutiveFrameId() {
return this->next_part++;
}
std::weak_ptr<J2534MessageFilter> filter;
unsigned long flags;
unsigned long expected_size;
std::string msg;
unsigned char next_part;
};

View File

@@ -0,0 +1,25 @@
#pragma once
#include "Action.h"
#include "J2534Frame.h"
class J2534Connection;
class MessageTx : public Action, public std::enable_shared_from_this<MessageTx>
{
public:
MessageTx(
std::weak_ptr<J2534Connection> connection_in,
PASSTHRU_MSG& to_send
) : Action(connection_in), fullmsg(to_send) { };
virtual BOOL checkTxReceipt(J2534Frame frame) = 0;
virtual BOOL isFinished() = 0;
virtual BOOL txReady() = 0;
virtual void reset() = 0;
protected:
J2534Frame fullmsg;
};

View File

@@ -0,0 +1,52 @@
#pragma once
#include "Action.h"
#include "MessageTx.h"
class MessageTxTimeout;
/* A special type of MessageTx for multipart messages that supports being canceled with a timeout.*/
class MessageTxTimeoutable : public MessageTx
{
public:
MessageTxTimeoutable(
std::weak_ptr<J2534Connection> connection,
PASSTHRU_MSG& to_send
);
unsigned long getRecvCount() {
return recvCount;
}
virtual void onTimeout() = 0;
protected:
unsigned long recvCount;
void scheduleTimeout(std::chrono::microseconds timeoutus);
void scheduleTimeout(unsigned long timeoutus);
};
/* An Action that cancels MessageTxTimeoutableif the Timeout Actoin executes
before the MessageTxTimeoutableif renews its timeout.
*/
class MessageTxTimeout : public Action
{
public:
MessageTxTimeout(
std::shared_ptr<MessageTxTimeoutable> msg,
std::chrono::microseconds timeout
);
MessageTxTimeout(
std::shared_ptr<MessageTxTimeoutable> msg,
unsigned long timeout
);
virtual void execute();
private:
std::weak_ptr<MessageTxTimeoutable> msg;
unsigned long lastRecvCount;
};

View File

@@ -0,0 +1,33 @@
#pragma once
#include <memory>
#include "MessageTx.h"
class J2534Connection;
class MessageTx_CAN : public MessageTx
{
public:
MessageTx_CAN(
std::shared_ptr<J2534Connection> connection_in,
PASSTHRU_MSG& to_send
);
virtual void execute();
//Returns TRUE if receipt is consumed by the msg, FALSE otherwise.
virtual BOOL checkTxReceipt(J2534Frame frame);
virtual BOOL isFinished() {
return !txInFlight && sentyet;
};
virtual BOOL txReady() {
return !sentyet;
};
virtual void reset();
private:
BOOL sentyet;
BOOL txInFlight;
};

View File

@@ -0,0 +1,32 @@
#pragma once
#include <memory>
#include "MessageTx.h"
class J2534Connection;
class MessageTx_ISO14230 : public MessageTx
{
public:
MessageTx_ISO14230(
std::shared_ptr<J2534Connection> connection_in,
PASSTHRU_MSG& to_send
);
virtual void execute();
virtual BOOL checkTxReceipt(J2534Frame frame);
virtual BOOL isFinished() {
return !txInFlight && sentyet;
};
virtual BOOL txReady() {
return !sentyet;
};
virtual void reset();
private:
BOOL sentyet;
BOOL txInFlight;
};

View File

@@ -0,0 +1,54 @@
#pragma once
#include "MessageTxTimeout.h"
#include "J2534Connection_ISO15765.h"
class J2534Connection_ISO15765;
/**
A specialized message type that can handle J2534 single and multi
frame (with flow control) writes.
*/
class MessageTx_ISO15765 : public MessageTxTimeoutable
{
public:
MessageTx_ISO15765(
std::shared_ptr<J2534Connection> connection,
PASSTHRU_MSG& to_send,
std::shared_ptr<J2534MessageFilter> filter
);
unsigned int addressLength();
virtual void execute();
virtual BOOL checkTxReceipt(J2534Frame frame);
virtual BOOL isFinished();
virtual BOOL txReady();
virtual void reset();
virtual void onTimeout();
//Functions for ISO15765 flow control
void MessageTx_ISO15765::flowControlContinue(uint8_t block_size, std::chrono::microseconds separation_time);
void MessageTx_ISO15765::flowControlWait(unsigned long N_WFTmax);
void MessageTx_ISO15765::flowControlAbort();
std::shared_ptr<J2534MessageFilter> filter;
unsigned long frames_sent;
unsigned long consumed_count;
uint8_t block_size;
unsigned long CANid;
std::string data_prefix;
std::string payload;
BOOL isMultipart;
std::vector<std::string> framePayloads;
BOOL txInFlight;
BOOL sendAll;
unsigned int numWaitFrames;
BOOL didtimeout;
BOOL issuspended;
};

View File

@@ -0,0 +1,95 @@
#pragma once
#include <memory>
#include <list>
#include <queue>
#include <set>
#include <chrono>
#include "J2534_v0404.h"
#include "panda_shared/panda.h"
#include "synchronize.h"
#include "Action.h"
#include "MessageTx.h"
#include "J2534Connection.h"
class J2534Connection;
class Action;
class MessageTx;
/**
Class representing a physical panda adapter. Instances are created by
PassThruOpen in the J2534 API. A Device can create one or more
J2534Connections.
*/
class PandaJ2534Device {
public:
PandaJ2534Device(std::unique_ptr<panda::Panda> new_panda);
~PandaJ2534Device();
static std::shared_ptr<PandaJ2534Device> openByName(std::string sn);
DWORD closeChannel(unsigned long ChannelID);
DWORD addChannel(std::shared_ptr<J2534Connection>& conn, unsigned long* channel_id);
std::unique_ptr<panda::Panda> panda;
std::vector<std::shared_ptr<J2534Connection>> connections;
//Place the Action in the task queue based on the Action's expiration time,
//then signal the thread that processes actions.
void insertActionIntoTaskList(std::shared_ptr<Action> action);
void scheduleAction(std::shared_ptr<Action> msg, BOOL startdelayed=FALSE);
void registerConnectionTx(std::shared_ptr<J2534Connection> conn);
//Resume sending messages from the provided Connection's TX queue.
void unstallConnectionTx(std::shared_ptr<J2534Connection> conn);
//Cleans up several queues after a message completes, is canceled, or otherwise goes away.
void removeConnectionTopAction(std::shared_ptr<J2534Connection> conn, std::shared_ptr<MessageTx> msg);
//Messages that have been sent on the wire will be echoed by the panda when
//transmission is complete. This tracks what is still waiting to hear an echo.
std::queue<std::shared_ptr<MessageTx>> txMsgsAwaitingEcho;
std::string kline_five_baud_init(uint8_t addr);
std::string kline_wakeup_start_comm(std::string& start_comm);
BOOL kline_send(std::string& data);
private:
HANDLE thread_kill_event;
HANDLE kline_recv_handle;
static DWORD WINAPI _kline_recv_threadBootstrap(LPVOID This) {
return ((PandaJ2534Device*)This)->kline_recv_thread();
}
DWORD kline_recv_thread();
HANDLE can_recv_handle;
static DWORD WINAPI _can_recv_threadBootstrap(LPVOID This) {
return ((PandaJ2534Device*)This)->can_recv_thread();
}
DWORD can_recv_thread();
HANDLE can_process_handle;
static DWORD WINAPI _can_process_threadBootstrap(LPVOID This) {
return ((PandaJ2534Device*)This)->can_process_thread();
}
DWORD can_process_thread();
HANDLE flow_control_wakeup_event;
HANDLE flow_control_thread_handle;
static DWORD WINAPI _msg_tx_threadBootstrap(LPVOID This) {
return ((PandaJ2534Device*)This)->msg_tx_thread();
}
DWORD msg_tx_thread();
std::list<std::shared_ptr<Action>> task_queue;
Mutex task_queue_mutex;
std::queue<std::shared_ptr<J2534Connection>> ConnTxQueue;
std::set<std::shared_ptr<J2534Connection>> ConnTxSet;
Mutex connTXSet_mutex;
BOOL txInProgress;
Mutex kline_rx_mutex;
};

View File

@@ -0,0 +1,18 @@
#pragma once
#include <chrono>
//Copied from https://stackoverflow.com/a/31488113
class Timer
{
using clock = std::chrono::steady_clock;
using time_point_type = std::chrono::time_point < clock, std::chrono::milliseconds >;
public:
Timer();
// gets the time elapsed from construction.
unsigned long long /*milliseconds*/ getTimePassed();
private:
time_point_type start;
};

View File

@@ -0,0 +1,20 @@
#pragma once
#define msg_is_extaddr(msg) check_bmask(msg->TxFlags, ISO15765_ADDR_TYPE)
#define msg_is_padded(msg) check_bmask(msg->TxFlags, ISO15765_FRAME_PAD)
#define FRAME_SINGLE 0x00
#define FRAME_FIRST 0x10
#define FRAME_CONSEC 0x20
#define FRAME_FLOWCTRL 0x30
#define FLOWCTRL_CONTINUE 0
#define FLOWCTRL_WAIT 1
#define FLOWCTRL_ABORT 2
#define msg_get_type(msg, addrlen) ((msg).Data[addrlen] & 0xF0)
#define is_single(msg, addrlen) (msg_get_type(msg, addrlen) == FRAME_SINGLE)
#define is_first(msg, addrlen) (msg_get_type(msg, addrlen) == FRAME_FIRST)
#define is_consecutive(msg, addrlen) (msg_get_type(msg, addrlen) == FRAME_CONSEC)
#define is_flowctrl(msg, addrlen) (msg_get_type(msg, addrlen) == FRAME_FLOWCTRL)

View File

@@ -0,0 +1,4 @@
#pragma once
#include "stdafx.h"
extern HMODULE thisdll;

Binary file not shown.

View File

@@ -0,0 +1,152 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{A2BB18A5-F26B-48D6-BBB5-B83D64473C77}</ProjectGuid>
<Keyword>Win32Proj</Keyword>
<RootNamespace>pandaJ2534DLL</RootNamespace>
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="Shared">
<Import Project="..\panda_shared\panda_shared.vcxitems" Label="Shared" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<LinkIncremental>true</LinkIncremental>
<OutDir>$(SolutionDir)$(Configuration)_$(PlatformShortName)\</OutDir>
<TargetName>pandaJ2534_0404_32</TargetName>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LinkIncremental>false</LinkIncremental>
<OutDir>$(SolutionDir)$(Configuration)_$(PlatformShortName)\</OutDir>
<TargetName>pandaJ2534_0404_32</TargetName>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<PrecompiledHeader>Use</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;_USRDLL;PANDAJ2534DLL_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<SDLCheck>true</SDLCheck>
<AdditionalIncludeDirectories>$(SolutionDir);</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);version.lib;winusb.lib;setupapi.lib</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<PrecompiledHeader>Use</PrecompiledHeader>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;PANDAJ2534DLL_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<SDLCheck>true</SDLCheck>
<AdditionalIncludeDirectories>$(SolutionDir);</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);version.lib;winusb.lib;setupapi.lib</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClInclude Include="..\panda\panda.h" />
<ClInclude Include="constants_ISO15765.h" />
<ClInclude Include="dllmain.h" />
<ClInclude Include="J2534Connection_ISO14230.h" />
<ClInclude Include="MessagePeriodic.h" />
<ClInclude Include="MessageRx.h" />
<ClInclude Include="J2534Connection.h" />
<ClInclude Include="J2534Connection_CAN.h" />
<ClInclude Include="J2534Connection_ISO15765.h" />
<ClInclude Include="J2534Frame.h" />
<ClInclude Include="J2534MessageFilter.h" />
<ClInclude Include="J2534_v0404.h" />
<ClInclude Include="Action.h" />
<ClInclude Include="MessageTx.h" />
<ClInclude Include="MessageTxTimeout.h" />
<ClInclude Include="MessageTx_CAN.h" />
<ClInclude Include="MessageTx_ISO14230.h" />
<ClInclude Include="MessageTx_ISO15765.h" />
<ClInclude Include="PandaJ2534Device.h" />
<ClInclude Include="resource.h" />
<ClInclude Include="stdafx.h" />
<ClInclude Include="synchronize.h" />
<ClInclude Include="targetver.h" />
<ClInclude Include="Timer.h" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="dllmain.cpp">
<CompileAsManaged Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">false</CompileAsManaged>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
</PrecompiledHeader>
<CompileAsManaged Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</CompileAsManaged>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
</PrecompiledHeader>
</ClCompile>
<ClCompile Include="J2534Connection.cpp" />
<ClCompile Include="J2534Connection_CAN.cpp" />
<ClCompile Include="J2534Connection_ISO14230.cpp" />
<ClCompile Include="J2534Connection_ISO15765.cpp" />
<ClCompile Include="J2534MessageFilter.cpp" />
<ClCompile Include="MessagePeriodic.cpp" />
<ClCompile Include="MessageTxTimeout.cpp" />
<ClCompile Include="MessageTx_CAN.cpp" />
<ClCompile Include="MessageTx_ISO14230.cpp" />
<ClCompile Include="MessageTx_ISO15765.cpp" />
<ClCompile Include="PandaJ2534Device.cpp" />
<ClCompile Include="pandaJ2534DLL.cpp" />
<ClCompile Include="stdafx.cpp">
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Create</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Create</PrecompiledHeader>
</ClCompile>
<ClCompile Include="Timer.cpp" />
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="pandaJ2534DLL.rc" />
</ItemGroup>
<ItemGroup>
<None Include="ClassDiagram.cd" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

View File

@@ -0,0 +1,173 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="Source Files">
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
</Filter>
<Filter Include="Header Files">
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
<Extensions>h;hh;hpp;hxx;hm;inl;inc;xsd</Extensions>
</Filter>
<Filter Include="Resource Files">
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
</Filter>
<Filter Include="Header Files\depends">
<UniqueIdentifier>{a4cd0bce-0a2a-43d9-9c9f-b21a3b607e90}</UniqueIdentifier>
</Filter>
<Filter Include="Header Files\boilerplate">
<UniqueIdentifier>{a85ee263-380d-4d37-b167-6629cfd5177f}</UniqueIdentifier>
</Filter>
<Filter Include="Source Files\boilerplate">
<UniqueIdentifier>{010a0176-a146-4d3a-824a-fd683904774d}</UniqueIdentifier>
</Filter>
<Filter Include="Header Files\J2534_CAN">
<UniqueIdentifier>{71c9502a-ee59-4d5e-873f-c9cc792e7c76}</UniqueIdentifier>
</Filter>
<Filter Include="Header Files\J2534_ISO15765">
<UniqueIdentifier>{4fd3183a-c457-430c-b762-f767a5788bca}</UniqueIdentifier>
</Filter>
<Filter Include="Source Files\J2534_ISO15765">
<UniqueIdentifier>{53cd179e-22d8-43e2-bc61-516d3861fae6}</UniqueIdentifier>
</Filter>
<Filter Include="Source Files\J2534_CAN">
<UniqueIdentifier>{08d548b5-4d0b-4ce4-85e6-5ff3fc987758}</UniqueIdentifier>
</Filter>
<Filter Include="Source Files\J2534_ISO14230">
<UniqueIdentifier>{b5c1874e-d3f8-4465-89c5-2e2b7e9f4fa4}</UniqueIdentifier>
</Filter>
<Filter Include="Header Files\J2534_ISO14230">
<UniqueIdentifier>{b5a39015-f3ca-4888-bd5f-785aeec91345}</UniqueIdentifier>
</Filter>
</ItemGroup>
<ItemGroup>
<ClInclude Include="J2534Connection.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="PandaJ2534Device.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="Timer.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="J2534MessageFilter.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="synchronize.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="J2534Connection_CAN.h">
<Filter>Header Files\J2534_CAN</Filter>
</ClInclude>
<ClInclude Include="J2534Connection_ISO15765.h">
<Filter>Header Files\J2534_ISO15765</Filter>
</ClInclude>
<ClInclude Include="J2534_v0404.h">
<Filter>Header Files\depends</Filter>
</ClInclude>
<ClInclude Include="..\panda\panda.h">
<Filter>Header Files\depends</Filter>
</ClInclude>
<ClInclude Include="dllmain.h">
<Filter>Header Files\boilerplate</Filter>
</ClInclude>
<ClInclude Include="resource.h">
<Filter>Header Files\boilerplate</Filter>
</ClInclude>
<ClInclude Include="stdafx.h">
<Filter>Header Files\boilerplate</Filter>
</ClInclude>
<ClInclude Include="targetver.h">
<Filter>Header Files\boilerplate</Filter>
</ClInclude>
<ClInclude Include="J2534Frame.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="MessageTx_ISO15765.h">
<Filter>Header Files\J2534_ISO15765</Filter>
</ClInclude>
<ClInclude Include="MessageRx.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="constants_ISO15765.h">
<Filter>Header Files\J2534_ISO15765</Filter>
</ClInclude>
<ClInclude Include="MessageTx_CAN.h">
<Filter>Header Files\J2534_CAN</Filter>
</ClInclude>
<ClInclude Include="MessageTxTimeout.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="Action.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="MessageTx.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="MessagePeriodic.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="J2534Connection_ISO14230.h">
<Filter>Header Files\J2534_ISO14230</Filter>
</ClInclude>
<ClInclude Include="MessageTx_ISO14230.h">
<Filter>Header Files\J2534_ISO14230</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="pandaJ2534DLL.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="J2534Connection.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="PandaJ2534Device.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="Timer.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="J2534MessageFilter.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="J2534Connection_CAN.cpp">
<Filter>Source Files\J2534_CAN</Filter>
</ClCompile>
<ClCompile Include="J2534Connection_ISO15765.cpp">
<Filter>Source Files\J2534_ISO15765</Filter>
</ClCompile>
<ClCompile Include="dllmain.cpp">
<Filter>Source Files\boilerplate</Filter>
</ClCompile>
<ClCompile Include="stdafx.cpp">
<Filter>Source Files\boilerplate</Filter>
</ClCompile>
<ClCompile Include="MessageTx_ISO15765.cpp">
<Filter>Source Files\J2534_ISO15765</Filter>
</ClCompile>
<ClCompile Include="MessageTxTimeout.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="MessageTx_CAN.cpp">
<Filter>Source Files\J2534_CAN</Filter>
</ClCompile>
<ClCompile Include="MessagePeriodic.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="J2534Connection_ISO14230.cpp">
<Filter>Source Files\J2534_ISO14230</Filter>
</ClCompile>
<ClCompile Include="MessageTx_ISO14230.cpp">
<Filter>Source Files\J2534_ISO14230</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="pandaJ2534DLL.rc">
<Filter>Resource Files</Filter>
</ResourceCompile>
</ItemGroup>
<ItemGroup>
<None Include="ClassDiagram.cd" />
</ItemGroup>
</Project>

View File

@@ -0,0 +1,14 @@
//{{NO_DEPENDENCIES}}
// Microsoft Visual C++ generated include file.
// Used by pandaJ2534DLL.rc
// Next default values for new objects
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 101
#define _APS_NEXT_COMMAND_VALUE 40001
#define _APS_NEXT_CONTROL_VALUE 1001
#define _APS_NEXT_SYMED_VALUE 101
#endif
#endif

View File

@@ -0,0 +1,14 @@
#pragma once
#include "targetver.h"
#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
// Windows Header Files:
#include <windows.h>
#include <string>
#include <array>
#include <queue>
#include <ctime>
#include <chrono>
#include <tchar.h>

View File

@@ -0,0 +1,56 @@
#pragma once
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
//Inspired/directly copied from https://www.codeproject.com/Articles/12362/A-quot-synchronized-quot-statement-for-C-like-in-J
//Enables easier synchronization
class Mutex {
public:
Mutex() {
InitializeCriticalSectionAndSpinCount(&critSection, 0x00000400);
//InitializeCriticalSection(&critSection);
}
~Mutex() {
DeleteCriticalSection(&critSection);
}
void lock() {
EnterCriticalSection(&critSection);
}
void unlock() {
LeaveCriticalSection(&critSection);
}
private:
CRITICAL_SECTION critSection;
};
//Synchronization Controller Object
class Lock {
public:
Lock(Mutex &m) : mutex(m), locked(TRUE) {
m.lock();
}
~Lock() {
mutex.unlock();
}
operator bool() const {
return locked;
}
void setUnlock() {
locked = FALSE;
}
private:
Mutex& mutex;
bool locked;
};
//A useful shorthand for locking and unlocking a mutex over a scope.
//CAUTION, implemented with a for loop, so break/continue are consumed.
#define synchronized(M) for(Lock M##_lock = M; M##_lock; M##_lock.setUnlock())

View File

@@ -0,0 +1,13 @@
#pragma once
// Including SDKDDKVer.h defines the highest available Windows platform.
// If you wish to build your application for a previous Windows platform, include WinSDKVer.h and
// set the _WIN32_WINNT macro to the platform you wish to support before including SDKDDKVer.h.
#include <WinSDKVer.h>
#define WINVER _WIN32_WINNT_WIN7
#define _WIN32_WINNT _WIN32_WINNT_WIN7
#include <SDKDDKVer.h>

View File

@@ -0,0 +1,214 @@
!define J2534_Reg_Path "Software\PassThruSupport.04.04\comma.ai - panda"
!define Install_Name "panda J2534 driver"
;NOTE! The panda software requires a VC runtime to be installed in order to work.
;This installer must be bundled with the appropriate runtime installer, and have
;the installation registry key set so the installer can tell if the runtime is
;already installed. Copy vscruntimeinfo.nsh.sample to vscruntimeinfo.nsh and edit
;it for your version of Visual Studio.
!include "redist\vscruntimeinfo.nsh"
;--------------------------------
;Include Modern UI
!include "MUI2.nsh"
!include "x64.nsh"
!define MUI_ICON "panda.ico"
;NSIS is ignoring the unicon unless it is the same as the normal icon
;!define MUI_UNICON "panda_remove.ico"
;Properly display all languages (Installer will not work on Windows 95, 98 or ME!)
Unicode true
# Set the installer display name
Name "${Install_Name}"
# set the name of the installer
Outfile "${Install_Name} install.exe"
; The default installation directory
InstallDir $PROGRAMFILES\comma.ai\panda
; Request application privileges for UAC
RequestExecutionLevel admin
; Registry key to check for directory (so if you install again, it will
; overwrite the old one automatically)
InstallDirRegKey HKLM "SOFTWARE\${Install_Name}" "Install_Dir"
;--------------------------------
; Pages
!insertmacro MUI_PAGE_WELCOME
!insertmacro MUI_PAGE_LICENSE "..\..\LICENSE"
!insertmacro MUI_PAGE_COMPONENTS
!insertmacro MUI_PAGE_DIRECTORY
!insertmacro MUI_PAGE_INSTFILES
!insertmacro MUI_UNPAGE_CONFIRM
!insertmacro MUI_UNPAGE_INSTFILES
!insertmacro MUI_LANGUAGE "English" ;first language is the default language
; -------------------------------------------------------------------------------------------------
; Additional info (will appear in the "details" tab of the properties window for the installer)
VIAddVersionKey /LANG=${LANG_ENGLISH} "ProductName" "panda OBD-II adapter"
VIAddVersionKey /LANG=${LANG_ENGLISH} "Comments" ""
VIAddVersionKey /LANG=${LANG_ENGLISH} "CompanyName" "comma.ai"
VIAddVersionKey /LANG=${LANG_ENGLISH} "LegalTrademarks" "Application released under the MIT license"
;VIAddVersionKey /LANG=${LANG_ENGLISH} "LegalCopyright" "© ${PRODUCT_NAME} Team"
;VIAddVersionKey /LANG=${LANG_ENGLISH} "FileDescription" "Jessy Exum"
;VIAddVersionKey /LANG=${LANG_ENGLISH} "FileVersion" "${PRODUCT_VERSION}"
VIProductVersion "1.0.0.0"
;--------------------------------
; Install Sections
Section "prerequisites"
SectionIn RO
SetOutPath "$INSTDIR"
File "panda.ico"
;If the visual studio version this project is compiled with changes, this section
;must be revisited. The registry key must be changed, and the VS redistributable
;binary must be updated to the VS version used.
ClearErrors
ReadRegStr $0 HKCR ${VCRuntimeRegKey} "Version"
${If} ${Errors}
DetailPrint "Installing Visual Studio C Runtime..."
File "${VCRuntimeSetupPath}\${VCRuntimeSetupFile}"
ExecWait '"$INSTDIR\${VCRuntimeSetupFile}" /passive /norestart'
${Else}
DetailPrint "Visual Studio C Runtime already installed."
${EndIf}
;Remove the now unnecessary runtime installer.
Delete "$INSTDIR\${VCRuntimeSetupFile}"
;Do the rest of the install
; SetOutPath "$INSTDIR\driver"
; The inf file works for both 32 and 64 bit.
; File "Debug_x86\panda Driver Package\panda.inf"
; File "Debug_x86\panda Driver Package\panda.cat"
; ${DisableX64FSRedirection}
; nsExec::ExecToLog '"$SYSDIR\PnPutil.exe" /a "$INSTDIR\driver\panda.inf"'
; ${EnableX64FSRedirection}
; Write the installation path into the registry
WriteRegStr HKLM "SOFTWARE\${Install_Name}" "Install_Dir" "$INSTDIR"
; Write the uninstall keys for Windows
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${Install_Name}" "DisplayVersion" ""
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${Install_Name}" "DisplayIcon" '"$INSTDIR\panda.ico",0'
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${Install_Name}" "DisplayName" "${Install_Name}"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${Install_Name}" "Publisher" "comma.ai"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${Install_Name}" "UninstallString" '"$INSTDIR\uninstall.exe"'
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${Install_Name}" "URLInfoAbout" "https://github.com/commaai/panda/"
WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${Install_Name}" "NoModify" 1
WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${Install_Name}" "NoRepair" 1
SetOutPath $INSTDIR
WriteUninstaller "uninstall.exe"
SectionEnd
Section "J2534 Driver"
SetOutPath $INSTDIR
File Release_x86\pandaJ2534_0404_32.dll
SetRegView 32
WriteRegDWORD HKLM "${J2534_Reg_Path}" "CAN" 00000001
WriteRegStr HKLM "${J2534_Reg_Path}" "FunctionLibrary" "$INSTDIR\pandaJ2534_0404_32.dll"
WriteRegDWORD HKLM "${J2534_Reg_Path}" "ISO15765" 00000001
WriteRegDWORD HKLM "${J2534_Reg_Path}" "J1850VPW" 00000000
WriteRegDWORD HKLM "${J2534_Reg_Path}" "SCI_A_ENGINE" 00000000
WriteRegDWORD HKLM "${J2534_Reg_Path}" "SCI_A_TRANS" 00000000
WriteRegDWORD HKLM "${J2534_Reg_Path}" "SCI_B_ENGINE" 00000000
WriteRegDWORD HKLM "${J2534_Reg_Path}" "SCI_B_TRANS" 00000000
WriteRegDWORD HKLM "${J2534_Reg_Path}" "J1850PWM" 00000000
WriteRegDWORD HKLM "${J2534_Reg_Path}" "ISO9141" 00000001
WriteRegDWORD HKLM "${J2534_Reg_Path}" "ISO14230" 00000001
WriteRegStr HKLM "${J2534_Reg_Path}" "Name" "panda"
WriteRegStr HKLM "${J2534_Reg_Path}" "Vendor" "comma.ai"
WriteRegStr HKLM "${J2534_Reg_Path}" "ConfigApplication" ""
DetailPrint "Registered J2534 Driver"
SectionEnd
Section /o "Development lib/header"
SetOutPath $SYSDIR
File Release_x86\panda.dll
${If} ${RunningX64}
${DisableX64FSRedirection}
;Note that the x64 VS redistributable is not installed to prevent bloat.
;If you are the rare person who uses the 64 bit raw panda driver, please
;install the correct x64 VS runtime manually.
File Release_x64\panda.dll
${EnableX64FSRedirection}
${EndIf}
SetOutPath "$INSTDIR\devel"
File panda_shared\panda.h
SetOutPath "$INSTDIR\devel\x86"
File Release_x86\panda.lib
SetOutPath "$INSTDIR\devel\x64"
File Release_x64\panda.lib
SectionEnd
;--------------------------------
; Uninstaller
Section "Uninstall"
; Removing the inf file for winusb is not easy to do.
; The best solution I can find is parsing the output
; of the pnputil.exe /e command to find the oem#.inf
; file that lists comma.ai as the provider. Not sure
; if Microsoft wants these inf files to be removed.
; Consider https://blog.sverrirs.com/2015/12/creating-windows-installer-and.html
; These lines just remove the inf backups.
; Delete "$INSTDIR\driver\panda.inf"
; Delete "$INSTDIR\driver\panda.cat"
; RMDir "$INSTDIR\driver"
; Remove WinUSB driver library
Delete $SYSDIR\panda.dll
${If} ${RunningX64}
${DisableX64FSRedirection}
Delete $SYSDIR\panda.dll
${EnableX64FSRedirection}
${EndIf}
; Remove devel files
Delete "$INSTDIR\devel\x86\panda.lib"
RMDir "$INSTDIR\devel\x86"
Delete "$INSTDIR\devel\x64\panda.lib"
RMDir "$INSTDIR\devel\x64"
Delete "$INSTDIR\devel\panda.h"
RMDir "$INSTDIR\devel"
; Remove registry keys
DeleteRegKey HKLM "${J2534_Reg_Path}"
DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${Install_Name}"
DeleteRegKey HKLM "SOFTWARE\${Install_Name}"
; Remove files and uninstaller
Delete "$INSTDIR\uninstall.exe"
Delete "$INSTDIR\pandaJ2534_0404_32.dll"
Delete "$INSTDIR\panda.ico"
; Remove directories used
RMDir "$INSTDIR"
RMDir "$PROGRAMFILES\comma.ai"
SectionEnd

View File

@@ -0,0 +1,40 @@
========================================================================
CONSOLE APPLICATION : panda_playground Project Overview
========================================================================
AppWizard has created this panda_playground application for you.
This file contains a summary of what you will find in each of the files that
make up your panda_playground application.
panda_playground.vcxproj
This is the main project file for VC++ projects generated using an Application Wizard.
It contains information about the version of Visual C++ that generated the file, and
information about the platforms, configurations, and project features selected with the
Application Wizard.
panda_playground.vcxproj.filters
This is the filters file for VC++ projects generated using an Application Wizard.
It contains information about the association between the files in your project
and the filters. This association is used in the IDE to show grouping of files with
similar extensions under a specific node (for e.g. ".cpp" files are associated with the
"Source Files" filter).
panda_playground.cpp
This is the main application source file.
/////////////////////////////////////////////////////////////////////////////
Other standard files:
StdAfx.h, StdAfx.cpp
These files are used to build a precompiled header (PCH) file
named panda_playground.pch and a precompiled types file named StdAfx.obj.
/////////////////////////////////////////////////////////////////////////////
Other notes:
AppWizard uses "TODO:" comments to indicate parts of the source code you
should add to or customize.
/////////////////////////////////////////////////////////////////////////////

View File

@@ -0,0 +1,191 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{691DB635-C272-4B98-897E-0505B970DCA9}</ProjectGuid>
<Keyword>Win32Proj</Keyword>
<RootNamespace>panda_playground</RootNamespace>
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="Shared">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<LinkIncremental>true</LinkIncremental>
<OutDir>$(SolutionDir)$(Configuration)_$(PlatformShortName)\</OutDir>
<TargetName>$(ProjectName)2</TargetName>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<LinkIncremental>true</LinkIncremental>
<OutDir>$(SolutionDir)$(Configuration)_$(PlatformShortName)\</OutDir>
<TargetName>$(ProjectName)</TargetName>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LinkIncremental>false</LinkIncremental>
<OutDir>$(SolutionDir)$(Configuration)_$(PlatformShortName)\</OutDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<LinkIncremental>false</LinkIncremental>
<OutDir>$(SolutionDir)$(Configuration)_$(PlatformShortName)\</OutDir>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<PrecompiledHeader>Use</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<SDLCheck>true</SDLCheck>
<AdditionalIncludeDirectories>%(AdditionalIncludeDirectories);$(SolutionDir)</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);$(OutDir)panda.lib;$(OutDir)ecusim.lib</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<PrecompiledHeader>Use</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<SDLCheck>true</SDLCheck>
<AdditionalIncludeDirectories>%(AdditionalIncludeDirectories);$(SolutionDir)</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);$(OutDir)panda.lib;$(OutDir)ecusim.lib</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<PrecompiledHeader>Use</PrecompiledHeader>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<SDLCheck>true</SDLCheck>
<AdditionalIncludeDirectories>%(AdditionalIncludeDirectories);$(SolutionDir)</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);$(OutDir)panda.lib;$(OutDir)ecusim.lib</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<PrecompiledHeader>Use</PrecompiledHeader>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<SDLCheck>true</SDLCheck>
<AdditionalIncludeDirectories>%(AdditionalIncludeDirectories);$(SolutionDir)</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);$(OutDir)panda.lib;$(OutDir)ecusim.lib</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<Text Include="ReadMe.txt" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\pandaJ2534DLL Test\Loader4.h" />
<ClInclude Include="..\panda\panda.h" />
<ClInclude Include="stdafx.h" />
<ClInclude Include="targetver.h" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\pandaJ2534DLL Test\Loader4.cpp" />
<ClCompile Include="panda_playground.cpp" />
<ClCompile Include="stdafx.cpp">
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Create</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Create</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Create</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Create</PrecompiledHeader>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\ECUsim DLL\ECUsim DLL.vcxproj">
<Project>{96e0e646-ee76-444d-9a77-a0cd7f781deb}</Project>
</ProjectReference>
<ProjectReference Include="..\pandaJ2534DLL\pandaJ2534DLL.vcxproj">
<Project>{a2bb18a5-f26b-48d6-bbb5-b83d64473c77}</Project>
</ProjectReference>
<ProjectReference Include="..\panda\panda.vcxproj">
<Project>{5528aefb-638d-49af-b9d4-965154e7d531}</Project>
</ProjectReference>
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

View File

@@ -0,0 +1,45 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="Source Files">
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
</Filter>
<Filter Include="Header Files">
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
<Extensions>h;hh;hpp;hxx;hm;inl;inc;xsd</Extensions>
</Filter>
<Filter Include="Resource Files">
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
</Filter>
</ItemGroup>
<ItemGroup>
<Text Include="ReadMe.txt" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="stdafx.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="targetver.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\panda\panda.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\pandaJ2534DLL Test\Loader4.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="stdafx.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="panda_playground.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\pandaJ2534DLL Test\Loader4.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
</Project>

View File

@@ -0,0 +1,17 @@
// stdafx.h : include file for standard system include files,
// or project specific include files that are used frequently, but
// are changed infrequently
//
#pragma once
#include "targetver.h"
#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
// Windows Header Files:
#include <windows.h>
#include <string>
#include <stdio.h>
#include <tchar.h>
#include <strsafe.h>

Some files were not shown because too many files have changed in this diff Show More