From: "Max S." <max@schneidersoft.net>
To: linux-can@vger.kernel.org
Subject: max is back
Date: Sat, 29 Dec 2012 22:50:15 +0000 [thread overview]
Message-ID: <1356821415.6901.159.camel@blackbox> (raw)
Hello all,
If anyone remembers I was working on a usb to can adapter. The Dev-kit I
was using was defective and put the project on hiatus. I've got a fresh
kit now and the first working firmware version.
I'm using a user-space driver for now, and have the basic workings
hashed out as follows. (for reception)
1) open the usb device.
2) send byte order indicator and host frame format to each can
interface.
char data[10];
uint16_t ekey = 0xbeef;
int len = sprintf(data,"%c%c""%c%c%c%c\n",
((uint8_t *)&ekey)[0],((uint8_t *)&ekey)[1],
(char)sizeof(struct can_frame),
(char)((size_t)(&((struct can_frame *)0)->can_id)),
(char)((size_t)(&((struct can_frame *)0)->can_dlc)),
(char)((size_t)(&((struct can_frame *)0)->data))
);
libusb_control_transfer( .... data, ... );
3) send baudrate/mode/other settings to each interface.
3) prepare/submit some usb requests
libusb_fill_bulk_transfer(transfer_object,
usb_device, endpoint,
(unsigned char *)&frame, sizeof(struct can_frame), transfer_callback,
NULL, 1000 );
4) callbacks are really clean and look something like this:
void transfer_callback(struct libusb_transfer *transfer){
struct can_frame *frame = (struct can_frame *)transfer->buffer;
switch(transfer->status){
case LIBUSB_TRANSFER_COMPLETED:;
//pass frame to can system
break;
//handle errors
}
libusb_submit_transfer(transfer);
}
I remember in an earlier discussion with Marc and Oliver describing this
method. Is this what you had in mind?
I can signal bus errors by creating genuine struct can_frame errors this
way as well. How would I signal buffer overrun on the device?
Regarding setting the baudrate. How is this normally done? direct access
to the TQs, propseg, phas1/2 seg, etc?
Now I have some questions regarding sending messages. actually I'd just
like more help understanding this:
>> To provide a state-of-the-art echo functionality the sk pointer
(skb->sk) is
>> sent along with the CAN frame. This allows to skb_free() the original
tx skb
>> and create a new one at rx time with the correct sk pointer, when the
frame is
>> echoed after successful transmission. As we are endian safe the sk
pointer can
>> be taken from the USB URB as-is. (For security reasons we should
probably not
>> take the pointer directly but double check with stored echo-skbs)
You are saying that the host sends an extra identifier with the can
frame to be sent, and that the firmware sends the entire frame with this
identifier back to indicate completion? so I need some message header?
How is time-stamping done with socket-can? struct can_frame (at least on
my system) has no 'time_stamp' member. How does an application using
socketcan benefit from time-stamping?
Best Regards,
Max S.
next reply other threads:[~2012-12-29 23:54 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-12-29 22:50 Max S. [this message]
2013-01-07 19:23 ` max is back Oliver Hartkopp
2013-01-12 20:29 ` struct can_bittiming/struct can_berr_counter Max S.
2013-01-15 16:40 ` Wolfgang Grandegger
2013-01-15 16:46 ` Wolfgang Grandegger
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1356821415.6901.159.camel@blackbox \
--to=max@schneidersoft.net \
--cc=linux-can@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).