Skip to content

Commit

Permalink
Merge pull request #15 from driftregion/0.6.0_rc
Browse files Browse the repository at this point in the history
0.6.0
  • Loading branch information
driftregion authored Jul 20, 2023
2 parents 1ba8709 + cb6b79b commit ba10d9c
Show file tree
Hide file tree
Showing 27 changed files with 1,874 additions and 2,149 deletions.
19 changes: 0 additions & 19 deletions .github/workflows/lint.yml

This file was deleted.

2 changes: 1 addition & 1 deletion .github/workflows/runtests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@ jobs:
steps:
- uses: actions/checkout@v3

- name: run test
- name: build and run unit test
run: make unit_test
9 changes: 7 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
.bazel-*
bazel-*
.rsync-filter
test_iso14229
client
server
server
corpus
*.profdata
*.profraw
.gdb_history
fuzzer
5 changes: 0 additions & 5 deletions BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,3 @@ cc_library(
srcs=[":isotp_c_srcs"],
copts=["-Wno-unused-parameter"],
)

cc_binary(
name="example_server",

)
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2022 Nick James Kirkby & Co-Operators
Copyright (c) Nick James Kirkby & Co-Operators

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
36 changes: 28 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,25 +1,45 @@
ifeq "$(TP)" "ISOTP_C"
SRCS += isotp-c/isotp.c examples/isotp-c_on_socketcan.c
CFLAGS += -DUDS_TP=UDS_TP_ISOTP_C
endif

cxx: CFLAGS+=-DUDS_TP=UDS_TP_CUSTOM
cxx: Makefile iso14229.c iso14229.h
$(CXX) iso14229.c $(CFLAGS) -c

unit_test: CFLAGS+=-DUDS_TP=UDS_TP_CUSTOM -DUDS_CUSTOM_MILLIS
unit_test: Makefile iso14229.h iso14229.c test_iso14229.c
$(CC) iso14229.c test_iso14229.c $(CFLAGS) $(LDFLAGS) -o test_iso14229
$(RUN) ./test_iso14229

client: examples/client.c examples/uds_params.h iso14229.h iso14229.c Makefile
$(CC) iso14229.c $< $(CFLAGS) -o $@
client: CFLAGS+=-g -DUDS_DBG_PRINT=printf
client: examples/client.c examples/uds_params.h iso14229.h iso14229.c Makefile $(SRCS)
$(CC) iso14229.c $(SRCS) $< $(CFLAGS) -o $@

server: examples/server.c examples/uds_params.h iso14229.h iso14229.c Makefile
$(CC) iso14229.c $< $(CFLAGS) -o $@
server: CFLAGS+=-g -DUDS_DBG_PRINT=printf
server: examples/server.c examples/uds_params.h iso14229.h iso14229.c Makefile $(SRCS)
$(CC) iso14229.c $(SRCS) $< $(CFLAGS) -o $@

test_examples: client server test_examples.sh
@./test_examples.sh
test_examples: test_examples.py
$(RUN) ./test_examples.py

uds_prefix: CFLAGS+=-DUDS_TP=UDS_TP_CUSTOM -DUDS_CUSTOM_MILLIS
uds_prefix: iso14229.c iso14229.h
$(CC) iso14229.c $(CFLAGS) -c -o /tmp/x.o && nm /tmp/x.o | grep ' T ' | grep -v 'UDS' ; test $$? = 1

test: unit_test test_examples uds_prefix
test_qemu: Makefile iso14229.h iso14229.c test_iso14229.c test_qemu.py
$(RUN) ./test_qemu.py

test: cxx unit_test test_examples uds_prefix test_qemu

fuzz: CC=clang-14
fuzz: ASAN = -fsanitize=fuzzer,signed-integer-overflow,address,undefined -fprofile-instr-generate -fcoverage-mapping
fuzz: OPTS = -g -DUDS_TP=UDS_TP_CUSTOM -DUDS_CUSTOM_MILLIS
fuzz: iso14229.c iso14229.h fuzz_server.c Makefile
$(CC) $(OPTS) $(WARN) $(INCS) $(TFLAGS) $(ASAN) fuzz_server.c iso14229.c -o fuzzer
$(RUN) ./fuzzer corpus

clean:
rm -f client server test_iso14229
rm -f client server test_iso14229 iso14229.o

.phony: clean test_examples
46 changes: 24 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,23 @@

iso14229 is a server and client session-layer implementation of (ISO14229-1:2013) targeting embedded systems. It is tested with [`isotp-c`](https://github.com/lishen2/isotp-c) as well as [linux kernel](https://github.com/linux-can/can-utils/blob/master/include/linux/can/isotp.h) ISO15765-2 (ISO-TP) transport layer implementations.

API status: **not yet stable**
API status: **stabilizing**

## quickstart: server

```c
#include "iso14229.h"

static uint8_t fn(UDSServer_t *srv, UDSServerEvent_t ev, const void *arg) {
return kServiceNotSupported;
switch (ev) {
case UDS_SRV_EVT_EcuReset: { // 0x10
UDSECUResetArgs_t *r = (UDSECUResetArgs_t *)arg;
printf("got ECUReset request of type %x\n", r->type);
return kPositiveResponse;
default:
return kServiceNotSupported;
}
}
}

int main() {
Expand All @@ -45,14 +53,12 @@ int main() {
| Define | Description | Valid values |
| - | - | - |
| `UDS_ARCH` | Select a porting target | `UDS_ARCH_CUSTOM`, `UDS_ARCH_UNIX` |
| `UDS_TP` | Select a transport layer | `UDS_TP_ISOTP_C`, `UDS_TP_LINUX_SOCKET` |
| `UDS_TP` | Select a transport layer | `UDS_TP_ISOTP_C`, `UDS_TP_ISOTP_SOCKET` |
| `UDS_CUSTOM_MILLIS` | Use your own `millis()` implementation | defined or not defined |

Features:
- all memory allocation is static
- architecture-independent
- tested: arm, x86-64, ppc
- tests run under qemu
- architecture-independent. tested on arm, x86-64, ppc, ppc64. see [test_qemu.py](./test_qemu.py)
- has many existing unit-tests and tests are easy to extend

## supported functions (server and client )
Expand All @@ -74,7 +80,7 @@ Features:
| 0x2F | input control by identifier ||
| 0x31 | routine control ||
| 0x34 | request download ||
| 0x35 | request upload | |
| 0x35 | request upload | |
| 0x36 | transfer data ||
| 0x37 | request transfer exit ||
| 0x38 | request file transfer ||
Expand Down Expand Up @@ -337,20 +343,6 @@ typedef struct {
make test
```

## qemu

```sh
CC=powerpc-linux-gnu-gcc make test_bin
qemu-ppc -L /usr/powerpc-linux-gnu test_bin
```
## wine

```sh
CC=x86_64-w64-mingw32-gcc make test_bin
wine test_bin.exe
```


# Contributing

contributions are welcome
Expand Down Expand Up @@ -405,11 +397,21 @@ MIT
- API cleanup: use `UDS` prefix on all exported functions
- API cleanup: use a single callback function for all server events

## 0.6.0
- breaking API changes:
- `UDSClientErr_t` merged into `UDSErr_t`
- `TP_SEND_INPROGRESS` renamed to `UDS_TP_SEND_IN_PROGRESS`
- refactored `UDSTpHandle_t` to encourage struct inheritance
- `UDS_TP_LINUX_SOCKET` renamed to `UDS_TP_ISOTP_SOCKET`
- added server fuzz test and qemu tests
- cleaned up example tests, added isotp-c on socketcan to examples
- added `UDS_SRV_EVT_DoScheduledReset`
- improve client error handling

---

# Design Docs


## ISO-TP interface

`iso14229` supports opaque transports. Use `Iso14229TpHandle_t` to wrap a transport.
Expand Down
33 changes: 22 additions & 11 deletions README_zh.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,15 @@ API状态: **未稳定**
#include "iso14229.h"

static uint8_t fn(UDSServer_t *srv, UDSServerEvent_t ev, const void *arg) {
return kServiceNotSupported;
switch (ev) {
case UDS_SRV_EVT_EcuReset: { // 0x10
UDSECUResetArgs_t *r = (UDSECUResetArgs_t *)arg;
printf("got ECUReset request of type %x\n", r->type);
return kPositiveResponse;
default:
return kServiceNotSupported;
}
}
}

int main() {
Expand All @@ -38,9 +46,7 @@ int main() {

特点:
- 静态内存分配
- 独立于处理器架构
- 测试了: arm, x86-64, ppc
- 可以用qemu测试更多
- 独立于处理器架构 测试了: arm, x86-64, ppc, ppc64。参考[test_qemu.py](./test_qemu.py)
- 单元测试又多又容易扩展

## 支持服务(服务器和客户端)
Expand All @@ -62,7 +68,7 @@ int main() {
| 0x2F | input control by identifier ||
| 0x31 | routine control ||
| 0x34 | request download ||
| 0x35 | request upload | |
| 0x35 | request upload | |
| 0x36 | transfer data ||
| 0x37 | request transfer exit ||
| 0x38 | request file transfer ||
Expand Down Expand Up @@ -317,10 +323,6 @@ typedef struct {

[examples/README.md](examples/README.md)

## 测试

[test_uds.c](test_uds.c)

### 运行测试

```sh
Expand Down Expand Up @@ -383,7 +385,7 @@ MIT
- 简化使用、放isotp-c初始化参数到服务器/客户端配置里面
- 删除重复服务器缓冲器

# 0.4.0
## 0.4.0
- 重构RDBIHandler:用安全memmove
- 尽可能不用enum在结构体里面
- 传输层可插件。现在支持linux内核ISO-TP驱动。`isotp-c`同时也支持。看看例子 [examples](./examples/README.md)
Expand All @@ -393,12 +395,21 @@ MIT
- 可用性: 默认传输层配置现在自带
- API整理: 用`UDS`前缀在所有导出函数上
- API整理: 服务器事件用单个回调函数

## 0.6.0
- API更改:
- `UDSClientErr_t`合并到`UDSErr_t`
- `TP_SEND_INPROGRESS`改名为`UDS_TP_SEND_IN_PROGRESS`
- 重构了`UDSTpHandle_t`
- `UDS_TP_LINUX_SOCKET`改名为`UDS_TP_ISOTP_SOCKET`
- 增加了服务器fuzz测试以及qemu测试
- 整理例子测试,例子增加了isotp-c/socketcan传输
- 增加了`UDS_SRV_EVT_DoScheduledReset`服务器事件
---


# 开发者文档


## 客户端请求状态机

```plantuml
Expand Down
Loading

0 comments on commit ba10d9c

Please sign in to comment.