CAN interface

Posted on
  • Hallo.
    Is it possible to use the CAN interface with Espruino? I have not found any module for it on this site...
    How can I connect with other device with CAN interface?

    My board is HYSTM-32 (VET6). I'd like to add a CAN driver to PB9, PB8 pins, but I don't know, how can I communicate by CAN...

  • Hi,

    While the chip itself can do CAN, there's no support for it in Espruino. To get something working you'd either have to make your own JS module using peek and poke, or you might have to write your own additions to Espruino in C code (in which case you could take advantage of ST's HAL library).

    I think your main source of information would be the chip's reference manual. Chapter 24 is on the CAN controller.

    Hope that helps!

  • Unfortunately I have no idea how can I include C-code into JS-project... Couldn't you advise me any link to read about it?

  • Well, info on building Espruino is here:

    https://github.com/espruino/Espruino

    And creating your own C files is here:

    https://github.com/espruino/Espruino/tree/master/libs

    If you can find some example code to use CAN on an STM32 board then that would be a great starting point. If you can split it up into various functions (initialise, get data, set data) then it would be almost as easy as copy/pasting it into a file in Espruino.

  • Ok, thanks, I will read it, at first sight it's not so easy...

    And you, do you plan to include similar library into Espruino?

  • If someone comes up with a library that doesn't take up loads of space of make Espruino unreliable then I'd love to include it.

    However I'm personally not going to include support. Most people seem to want to use it for talking to their car via OBD, and it'd be much easier if they just bought a bluetooth ELM327 dongle and then connected Espruino to it via bluetooth. Almost certainly cheaper than buying a single OBD connector too :)

  • BTW, maybe we could move this thread to Interfacing?

    I'd like to help you @Uhv but I have no way to test CAN here, and I've got no use for it. Let me know if you need help building the Espruino or understanding how to add a C library.

  • 2Gordon
    No, no, no. That's not for car, of course :-) We work with a system that consists of many modules. They communicate by CAN. The master (module) that is on PIC builded has anywhere an error in program that we cannot find :-(. I'd like to probe to communicate by Espruino with slaves, but there is no library hier for it...

    The way with building Espruino by myself seems me... mmm, not simple and long...

    2alexanderbrevig
    It will be great if you would help me.
    Certainly we can move this theme to Interfacing if you think that it will be better

  • @Uhv I think you'll be better off getting a hold of a premade CAN => RS232 device if you do not want to try building Espruino yourself. This is especially true if you project relies on CAN then you should have a way of debugging the bus.

    Maybe something like this: http://www.canusb.com/ ?

    I guess @Gordon will move this thread as he sees fit :)

  • @alexanderbrevig moved :)

    @Uhv, ahh interesting. I can see it would be handy - if it was blocking someone buying a whole bunch of Espruino boards I'd definitely put some effort in right now, but you're the only person to ask for it in a non-automotive sense, and you're using the HY boards ;)

  • @Gordon, the Espruino is very handy to test any algorithm: I can draft quickly anything and probe it in Espruino :-) And therefore I like it :-)

    What is the problem with HY? Isn't it good enough? There are flash, SD, LCD, touchscreen... Very nice board, isn't it?

  • No, the HY is a great board. The problem is the only way I can afford to keep working on Espruino is by selling my boards - so it doesn't really help me to spend a week working on something when it just means someone will buy a bunch of other boards :)

    It's also unfortunate that CAN isn't supported on the F401 chip, so even if I spend time on it, it only works on one of the 2 boards I sell.

  • Post a reply
    • Bold
    • Italics
    • Link
    • Image
    • List
    • Quote
    • code
    • Preview
About

CAN interface

Posted by Avatar for Uhv @Uhv

Actions