Open poppfd opened 11 months ago
We would have to introduce a new set of function otherwise we would break compatibility with existing code. Did you tried reading ERRNO directly from the script? The send-call itself is synchronous and this should be the only syscall in the call chain (except if nodejs is doing some hidden syscall).
Yea I understand backwards compatibility is a concern. I'm not super familiar with natively compiled C libraries for node so I thought you might have a more elegant solution.
Not sure what you mean by "the script". If you mean the node script, I did not think the C errno
variable was available in that scope. If I could get access to the errno
variable, it looks like node will parse it with util.getSystemErrorName(errno)
Like I said, I recompiled the can.cc
file to return the errno string instead of number of bytes sent. I found this to be a crude, but workable solution.
We can add an additional function to read the errno. Would that work?
Yea I think that would work. So if we detect a failed send, we can read the errno
and log from node.
The
RawChannel.send()
method returns -1 if the send cannot be completed. Could the method somehow return an object including theerrno
set by the socket.h -> send() method? Or better yet, return the string parsed bystrerror()
to translate the errno to the system specific error.I understand returning an object is less clear than number of bytes or -1. I'm hoping you might have an idea for how to cleanly provide this info.
I was debugging a CAN interface issue and found the send() returned -1. But I didn't realize I had a txqueuelen issue until I recompiled the socketcan C code to provide this errno context (
105 ENOBUFS No buffer space available
). It'd be nice if node-can could provide that error information.