Discussion:
CAN IOCTL API extension [1 Attachment]
(too old to reply)
Sebastien Lorquet sebastien@lorquet.fr [nuttx]
2016-06-22 10:45:58 UTC
Permalink
Hello Greg,

Please find attached a proposal to add some mode CAN IOCTL calls: These will be
useful for device autotest when the application boots.

It is redundant with the CONFIG_CAN_LOOPBACK option, which can just be
interpreted as a default setting.

If you are okay with it, can you please apply it?

Thanks,
--
Sébastien Lorquet
spudarnia@yahoo.com [nuttx]
2016-06-22 12:33:24 UTC
Permalink
Committed. I assume that more is to follow?
Sebastien Lorquet sebastien@lorquet.fr [nuttx]
2016-06-22 12:54:27 UTC
Permalink
Sure!

We need implementation now.

BTW, Do you know who wrote the STM32 CAN driver? It seems incomplete, and I am
having a hard time making it work. I dont think there is any error management
done yet?

My CAN hardware is experimental, so I'm hitting all possible problems one after
the other since I'm not in ideal hardware conditions and have no kown-good CAN
device to play with :)

Thanks!

Sebastien
Post by ***@yahoo.com [nuttx]
Committed. I assume that more is to follow?
david_s5@usa.net [nuttx]
2016-06-22 13:21:44 UTC
Permalink
Hi Sebastien,

I am not sure what sort of issues you are having. But I have written several uavcan bootloaders that uses nuttx without the os and have a very simple nuttx compatible stm32 B-CAN driver. It may help you validate your HW.

The source is here https://github.com/PX4/Firmware/tree/nuttx_v3/src/drivers/bootloaders https://github.com/PX4/Firmware/tree/nuttx_v3/src/drivers/bootloaders


You will need to build the px4cannode-v1_bootloader with:


`make px4cannode-v1_bootloader


It is targeted to a F103 on an olimexino-stm32 OLIMEXINO-STM32 - Open Source Hardware Board https://www.olimex.com/Products/Duino/STM32/OLIMEXINO-STM32/

https://www.olimex.com/Products/Duino/STM32/OLIMEXINO-STM32/

OLIMEXINO-STM32 - Open Source Hardware Board https://www.olimex.com/Products/Duino/STM32/OLIMEXINO-STM32/ Open Source Hardware MAPLE (ARDUINO-like) development board



View on www.olimex.com https://www.olimex.com/Products/Duino/STM32/OLIMEXINO-STM32/
Preview by Yahoo




Also candump and a USB2CAN - 8devices http://www.8devices.com/products/usb2can


USB2CAN - 8devices http://www.8devices.com/products/usb2can 8devices is a company engaged in development, manufacturing and sales of unique design and functionality electronic equipment.



View on www.8devices.com http://www.8devices.com/products/usb2can
Preview by Yahoo




has been invaluable!


David
Sebastien Lorquet sebastien@lorquet.fr [nuttx]
2016-06-22 23:31:54 UTC
Permalink
Hello

I validated the hardware: One of the transceivers was half-desoldered,
this was barely visible, only one side of the SOIC8 was slightly lifted
from the board...

Now it works, I can exchange CAN messages, but I am not sure the stm32
CAN driver in nuttx is able to detect such weird bus hardware errors...

The transmit error just locked up the driver.

Sebastien
Post by ***@usa.net [nuttx]
Hi Sebastien,
I am not sure what sort of issues you are having. But I have written
several uavcan bootloaders that uses nuttx without the os and have a
very simple nuttx compatible stm32 B-CAN driver. It may help you
validate your HW.
The source is here
https://github.com/PX4/Firmware/tree/nuttx_v3/src/drivers/bootloaders
`make px4cannode-v1_bootloader
It is targeted to a F103 on an olimexino-stm32 OLIMEXINO-STM32 - Open
Source Hardware Board
<https://www.olimex.com/Products/Duino/STM32/OLIMEXINO-STM32/>
image <https://www.olimex.com/Products/Duino/STM32/OLIMEXINO-STM32/>
OLIMEXINO-STM32 - Open Source Hardware Board
<https://www.olimex.com/Products/Duino/STM32/OLIMEXINO-STM32/>
Open Source Hardware MAPLE (ARDUINO-like) development board
View on www.olimex.com
<https://www.olimex.com/Products/Duino/STM32/OLIMEXINO-STM32/>
Preview by Yahoo
Also candump and a USB2CAN - 8devices
<http://www.8devices.com/products/usb2can>
Preview by Yahoo
USB2CAN - 8devices <http://www.8devices.com/products/usb2can>
8devices is a company engaged in development, manufactu ring and sales
of unique design and functionality electronic equipment.
View on www.8devices.com <http://www.8devices.com/products/usb2can>
has been invaluable!
David
david_s5@usa.net [nuttx]
2016-06-23 01:53:29 UTC
Permalink
Sebastien,


Glad you found it!


I have not vetted the nuttx stm32 driver. UAVCAN has it's own driver so PX4 use it. For the bootloaders to run in under 8K we have what you saw there.


David
spudarnia@yahoo.com [nuttx]
2016-06-23 13:25:40 UTC
Permalink
The STM32 CAN driver has no error reporting capability at all. Error reporting was just very recently added to the CAN driver interface definition by Frank Berkert. The interface supports extensive error reporting if enabled via CONFIG_CAN_ERRORS. However, no CAN lower half supports the error reporting except for the SAMV7 MCAN driver. Frank added that support there. But the other CAN drivers zero the error report data and have no logic in place to detect, encode, and report CAN errors.


Greg
Sebastien Lorquet sebastien@lorquet.fr [nuttx]
2016-06-23 15:55:52 UTC
Permalink
Hello

Thanks for the status information.

I will have a look at the MCAN driver, because error reporting is absolutely
essential for a reliable CAN bus driver.

I have started to do investigate that for stm32l4, but I think that I will send
you a port of the STM32L CAN IOCTLs for STM32Fx before.

----------

Also, are you interested in integrating a CAN helper library in canutils/libcan
with generic functions like:

void can_setbaud(int fd, int baud);
int can_getbaud(int fd);

void can_setloopback(int fd, bool loop);
bool can_getloopback(int fd);

void can_setsilent(int fd, bool silent);
bool can_getsilent(int fd);

?

Sebastien
Post by ***@yahoo.com [nuttx]
The STM32 CAN driver has no error reporting capability at all. Error reporting
was just very recently added to the CAN driver interface definition by Frank
Berkert. The interface supports extensive error reporting if enabled via
CONFIG_CAN_ERRORS. However, no CAN lower half supports the error reporting
except for the SAMV7 MCAN driver. Frank added that support there. But the
other CAN drivers zero the error report data and have no logic in place to
detect, encode, and report CAN errors.
Greg
spudarnia@yahoo.com [nuttx]
2016-06-23 16:06:51 UTC
Permalink
Post by Sebastien Lorquet ***@lorquet.fr [nuttx]
Also, are you interested in integrating a CAN helper library in canutils/libcan
void can_setbaud(int fd, int baud);
int can_getbaud(int fd);
void can_setloopback(int fd, bool loop);
bool can_getloopback(int fd);
void can_setsilent(int fd, bool silent);
bool can_getsilent(int fd);
Certainly! As long as this does not introduce any new, non-standard OS interfaces and acts only through IOCTL calls to drivers/can.c.

Greg
Sebastien Lorquet sebastien@lorquet.fr [nuttx]
2016-06-24 07:04:21 UTC
Permalink
Greg,

Of course these APIs are just convenient wrappers around IOCTL calls.

I will prepare a patch.

Sebastien
Post by Sebastien Lorquet ***@lorquet.fr [nuttx]
Post by Sebastien Lorquet ***@lorquet.fr [nuttx]
Also, are you interested in integrating a CAN helper library in
canutils/libcan
Post by Sebastien Lorquet ***@lorquet.fr [nuttx]
void can_setbaud(int fd, int baud);
int can_getbaud(int fd);
void can_setloopback(int fd, bool loop);
bool can_getloopback(int fd);
void can_setsilent(int fd, bool silent);
bool can_getsilent(int fd);
Certainly! As long as this does not introduce any new, non-standard OS
interfaces and acts only through IOCTL calls to drivers/can.c.
Greg
Sebastien Lorquet sebastien@lorquet.fr [nuttx]
2016-06-22 13:21:48 UTC
Permalink
Hello,

for the moment please find attached a big rename to enforce the stm23l4_ name
space, because else, the can_txready function can be defined twice, a static
bool in the driver and a global int in the upper layer.

Something similar should be done in stm32 but I will let Alan do this (hehe)

Sebastien
Post by Sebastien Lorquet ***@lorquet.fr [nuttx]
Sure!
We need implementation now.
BTW, Do you know who wrote the STM32 CAN driver? It seems incomplete, and I am
having a hard time making it work. I dont think there is any error management
done yet?
My CAN hardware is experimental, so I'm hitting all possible problems one after
the other since I'm not in ideal hardware conditions and have no kown-good CAN
device to play with :)
Thanks!
Sebastien
Committed. I assume that more is to follow?
spudarnia@yahoo.com [nuttx]
2016-06-22 13:36:55 UTC
Permalink
Committed -- Greg
Sebastien Lorquet sebastien@lorquet.fr [nuttx]
2016-06-22 14:05:10 UTC
Permalink
Greg,

Here is the implementation for the new IOCTLs (and a pair of typos)

Sébastien Lorquet
Post by ***@yahoo.com [nuttx]
Committed. I assume that more is to follow?
spudarnia@yahoo.com [nuttx]
2016-06-22 14:21:00 UTC
Permalink
I don't know how to apply the first patch. It is a 'diff -cc' format. It looks the difference of a difference. I don't how to apply that with 'patch'.
Sebastien Lorquet sebastien@lorquet.fr [nuttx]
2016-06-22 14:58:04 UTC
Permalink
woaw...

I dont exactly know that happened. I may have edited a conflicted file and git
made a 3-way diff.

Will send again asap.

Sébastien Lorquet
Post by ***@yahoo.com [nuttx]
I don't know how to apply the first patch. It is a 'diff -cc' format. It looks
the difference of a difference. I don't how to apply that with 'patch'.
Sebastien Lorquet sebastien@lorquet.fr [nuttx]
2016-06-22 15:06:31 UTC
Permalink
Here is the correct patch. Sorry for the time lost.

Sebastien
Post by ***@yahoo.com [nuttx]
I don't know how to apply the first patch. It is a 'diff -cc' format. It looks
the difference of a difference. I don't how to apply that with 'patch'.
spudarnia@yahoo.com [nuttx]
2016-06-22 16:02:41 UTC
Permalink
Comitted! Thanks, Greg.
Loading...