CAN bus in BB. Best way?

Hello,

I have to take data from a CAN bus, show this data in a LCD and also
forward the data to a web page by means a 3G usb modem. I'm using
Android Froyo v2.0.

I'm confused about how to interface CAN bus with my BB XM. Since
there's no expansion board, am I wrong?, I think I should to use a uC
with CAN and another port in order to make a bridge.

I've thought in some solutions but I'm still having severeal doubts:

- First solution would be to use USB CDC or HID. I guess I should
write a driver, since Android just recognize common usb peripherals
(mouse, keyboard, flash drive) Am I wrong? Quite difficult, not?

- Another way will be to use ethernet. But: Is possible to use 2
ethernet ports, at time, in Android? I mean: a local connection and a
3G modem...

- Last solution that I found would be to use I2C. Is it possible in
Android? Should I write a driver?

Any suggestion will be well appreciated. Thank you.

Hi MaNu,

I'm going to use CAN Bus in my project too. I found that the best
solution is MCP2515 CAN controller from Microchip (http://
www.microchip.com/wwwproducts/Devices.aspx?dDocName=en010406). You can
connect it to your BB using SPI bus on expansion connector. Linux
kernel has the driver for this chip (drivers/net/can/mcp251x.c) and in
userspace you can use SocketCAN networking stack.

Cheers,
Max.

I would also recommend the mcp2515 if your can bus traffic is low. The
mcp2515 only has two receive buffers so if you send bursts of messages
(over 2) then you will start to drop messages.

How much slow we are talking about? KB/S?.. I've never worked with
CAN.

and... If I'd use a PIC with CAN bus as a bridge?, i.e.:

http://www.microchip.com/wwwproducts/Devices.aspx?dDocName=en545655

Brochure says "2 x CAN2.0b modules with 1024 buffers"...

In this case: Could I communicate the PIC32MX with the BB-Android by
means CDC using USB API + Java Interface Native?... Too much complex?

I'd do the part of hardware and firmware (PIC) and a third party would
program the Android app...

Thank you.

I'm successfully using a MicroChip MCP2515 CAN controller connected to the
SPI bus.
You can configure the kernel to include the CAN support and the MCP251x
driver.
You end up with a normal network interface that can be configured in
/etc/network/interfaces as normal.
This allows you to use normal socket programming in your applications as
everything is built into the kernel and saves programming PICs and
developing your own protocols.
There is a recipe for a set of CAN utilities in the OE repository.
Details can be found at http://developer.berlios.de/projects/socketcan/

Cheers Mike.

My mcp2515 can do about 200kb/s with my gumstix (same core as the
beagleboard). The problem is with the number of receive buffers on the
mcp2515 (only 2) and the overhead of Linux Interrupts. There have been
alot of talk about this issue (search on google). My system requires
1Mb/s so I had to go the PIC route. Instead of the PIC32 I would use a
PIC24 and go through the UART or SPI on the beagleboard to make things
more simple.

This is pure uninformed speculation, but if interrupt overhead is a
problem, polling a la NAPI might raise your maximum bandwidth a little?

  I'd agree that 1Mbyte/s with 2 receive buffers is best described as
'hopeful' though.

Richard.