Hi experts!
I want to include a CAN hardware interface into NR.
How can I handle the events of the module?
JavaScript Events
The module emits the following events:
open when the serial port is successfully opened
error if an error occurs
data when an incoming CAN bus frame is received
write when an outgoing CAN bus frame is sent to the device (the event is emitted before the frame is actually sent on the bus)
close when the port is closed
full documentation: https://www.npmjs.com/package/@csllc/cs-pcan-usb
Any reason you are not using one of the pre-built node-red canbus nodes?
Because IĀ“m in a industrial environment and my company uses this interfaces.
um, ok, fine your company uses canbus interfaces. Great.
Perhaps my question was unclear. Let me ask a different way...
Is it not possible to use one of the existing pre-packaged canbus nodes that are already designed and working for Node-RED and dont require you to use a non packaged npm module?
all your linked nodes are for special interfaces (socketcan[linux only, we use windows] or special virtual magic interface)
@knolleary do you have any suggestions on how to handle javascript events?
Assuming for 1 second you are loading this lib in a function node, you handle events in a node-red function exactly the same as you would in any nodejs application
example
can.on('some-event', function(data) {
// do something with data e.g. send it out to next node
node.send(topic: 'some-event', {payload: data})
})
for more information read the function node docs
1 Like
This works, great!
I have no idea how an nodejs application works... ![:man_shrugging: :man_shrugging:](https://emoji.discourse-cdn.com/twitter/man_shrugging.png?v=12)
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.