Comments (1)
Setting the CAN_ISOTP_WAIT_TX_DONE
doesn't indeed affect the return value of write(2)
. Bellow a sample code illustrating this behavior:
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <net/if.h>
#include <linux/can.h>
#include <linux/can/isotp.h>
static const u_int8_t tx_buffer[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
int main() {
int status = 0;
int fd;
struct sockaddr_can address;
static struct can_isotp_options isotp_options;
static struct can_isotp_ll_options isotp_ll_loptions;
address.can_family = AF_CAN;
address.can_addr.tp.rx_id = 0x98DAF900u;
address.can_addr.tp.tx_id = 0x98DA00F9u;
address.can_ifindex = (signed) if_nametoindex("can1");
isotp_options.flags = CAN_ISOTP_DEFAULT_FLAGS | CAN_ISOTP_WAIT_TX_DONE;
isotp_ll_loptions.mtu = 16u;
isotp_ll_loptions.tx_dl = 8u;
isotp_ll_loptions.tx_flags = 0u;
if ((fd = socket(PF_CAN, SOCK_DGRAM, CAN_ISOTP)) >= 0) {
if ((setsockopt(fd, SOL_CAN_ISOTP, CAN_ISOTP_OPTS, &isotp_options, sizeof(isotp_options))) >= 0) {
if ((setsockopt(fd, SOL_CAN_ISOTP, CAN_ISOTP_LL_OPTS, &isotp_ll_loptions, sizeof(isotp_ll_loptions))) >= 0) {
if ((bind(fd, (struct sockaddr *)&address, sizeof(address))) >= 0) {
ssize_t result = write(fd, &tx_buffer, sizeof(tx_buffer) / sizeof(tx_buffer[0]));
printf("result = %d", result);
} else {
status = 4;
}
} else {
status = 3;
}
} else {
status = 2;
}
} else {
status = 1;
}
return status;
}
This executable outputs:
/home/pi/isotp/cmake-build-debug-rpi/isotp
result = 10
Process finished with exit code 0
While the can dump utility outputs:
$ candump can1
can1 18DA00F9 [8] 10 08 01 02 03 04 05 06
Should the call to write(2)
return a negative value? Or should it return the number of byte effectively written (in this case 6) if the writing operations are configured in blocking mode trough CAN_ISOTP_WAIT_TX_DONE
option?
from can-isotp.
Related Issues (20)
- Not able to build for raspberry pi HOT 1
- difference between python-can-isotp and can-isotp and stmin discrepancy HOT 2
- use read() function and add notify function. HOT 18
- ERRNO 84 on recv() HOT 2
- FlowControl: isotp vs. "real" OBD2 adapter behavior HOT 4
- how to send > 4095 isotp message HOT 3
- wait_tx_done does not seem to be working [RPi + python-can-isotp] HOT 31
- MAX_MSG_LENGTH to 66000 commit is missing from this repo HOT 1
- When trying to read 8K messages on ISO-TP socket using Classic CAN receive back -1 with errno 110 ETIMEDOUT HOT 5
- FlowControl frame address tx_id vs. rx_id - 8? HOT 2
- Unrecoverable error when using python socket with CAN_ISOTP. HOT 8
- Sending rate cannot be faster than 300us HOT 12
- unstable transmission of data: sequence number of consecutive frames get messed up HOT 3
- MSG_CMSG_COMPAT set by the kernel for `recvmsg` HOT 7
- Compiling of branch mainline-5.4+ HOT 2
- IP over CAN ISO-TP multi-host HOT 2
- Address extension in one direction but not the other HOT 2
- ISOTP module does not ignore the priority bits (high 3 bits of extended ID) HOT 4
- read: Network is down HOT 2
- missing feedback on expired timer for first flow control (FC) frame HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from can-isotp.