asynchronous usb communication
Moderator: RoccoMarco
asynchronous usb communication
hi, i am using usb shell implementation to get some string from board over usb. i would using asynchronous transfer from board to pc over usb because i do not want an excessive communication overhead. How can i do it?
- Giovanni
- Site Admin
- Posts: 14892
- Joined: Wed May 27, 2009 8:48 am
- Has thanked: 1202 times
- Been thanked: 996 times
Re: asynchronous usb communication
The SERIAL_USB driver used by the shell demo includes asynchronous read and write functions as well synchronous ones. Its interface is exactly the same of a normal serial driver.
Giovanni
Giovanni
Re: asynchronous usb communication
what is demo shell project so i can see. Thanks
I'm seeing that to write is performed on a usb chprintf().
how can I distinguish from synchronous to asynchronous?
I'm seeing that to write is performed on a usb chprintf().
how can I distinguish from synchronous to asynchronous?
- Giovanni
- Site Admin
- Posts: 14892
- Joined: Wed May 27, 2009 8:48 am
- Has thanked: 1202 times
- Been thanked: 996 times
Re: asynchronous usb communication
Pask wrote:i am using usb shell implementation to get some string from board over usb
This is the shell demo.
Pask wrote:how can I distinguish from synchronous to asynchronous?
I/O functions with TIME_IMMEDIATE as timeout parameter are asynchronous.
Giovanni
- Giovanni
- Site Admin
- Posts: 14892
- Joined: Wed May 27, 2009 8:48 am
- Has thanked: 1202 times
- Been thanked: 996 times
Re: asynchronous usb communication
but if I set time_immediate the operation stops immediately so the data when they are sent?
- Giovanni
- Site Admin
- Posts: 14892
- Joined: Wed May 27, 2009 8:48 am
- Has thanked: 1202 times
- Been thanked: 996 times
Re: asynchronous usb communication
The data is sent asynchronously like you asked.
BTW, there is no performance to be gained.
Giovanni
BTW, there is no performance to be gained.
Giovanni
Re: asynchronous usb communication
ok, but if i want to replace a shell command function with an asynchronous version of it how i can?
for example i have the following code:
can i replace BaseSequentialStream with BaseChannel type as required from chnWriteTimeout?
So i replace chprintf with chnWriteTimeout and that's it?
for example i have the following code:
Code: Select all
static const ShellCommand commands[] = {
{"mem", cmd_mem},
{"threads", cmd_threads},
{"test", cmd_test},
{"write", cmd_write},
{NULL, NULL}
};
static void cmd_mem(BaseSequentialStream *chp, int argc, char *argv[]) {
size_t n, size;
(void)argv;
if (argc > 0) {
chprintf(chp, "Usage: mem\r\n");
return;
}
n = chHeapStatus(NULL, &size);
chprintf(chp, "core free memory : %u bytes\r\n", chCoreStatus());
chprintf(chp, "heap fragments : %u\r\n", n);
chprintf(chp, "heap free total : %u bytes\r\n", size);
}
can i replace BaseSequentialStream with BaseChannel type as required from chnWriteTimeout?
So i replace chprintf with chnWriteTimeout and that's it?
- Giovanni
- Site Admin
- Posts: 14892
- Joined: Wed May 27, 2009 8:48 am
- Has thanked: 1202 times
- Been thanked: 996 times
Re: asynchronous usb communication
I don't understand what you are trying to do, probably we give a different meaning to the term.
Giovanni
Giovanni