sebi2k1 / node-can

NodeJS SocketCAN extension

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

can id data type

haticenurel opened this issue · comments

I would like to write an issue message regarding the problem with the can id number in this library.
The id numbers are being displayed as hex values (e.g., 0x7FF), and as a result, it doesn't show values beyond 0x7FF.
I believe using 'number' for representation limits the available space. Is there a way we can fix this?

To which tool do you refer? The dump script?

I meant send method

You have a code example? I don’t really understand the problem you are having.

You will understand when you try to send a message with can id bigger than 0x7FF to a channel . As you can see here:
async Dork() {
let i = 0x100;
const newData = [0x03, 0x20, 0x01, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA];

while (true) {
    this.channel.send({
        id: i,
        data: Buffer.from(newData), 
    });

    await this.Delay(2);

    if (i >= 0xFFF)
        break;
    i++;
}

}
The code keeps sending packets until the id value reaches 0xFFF. But this loop ends on 0x7FF. I think using 'number' for representation limits the available space.

Values > 0x7ff are not allowed when you send standard frame format by CAN spec. If you wanna send bigger values you have to send frames in extended frame format.

I didn't know that, thanks for letting me know.