add udev-find prog and ertm_usb_by_function to seek SillyCon Labs

parent 623f74da
......@@ -77,3 +77,4 @@ static const int ertm_ntemperatures =
extern int ertm_get_board_config(struct ertm_status *st, struct ertm14_board_state *bs);
extern char *ertm_find_usb_port(void);
extern char *ertm_usb_by_function(char *func);
#include <stdio.h>
#include <string.h>
#include "private.h"
int main(int argc, char *argv[])
{
char *devnode;
if (argc != 2) {
fprintf(stderr, "usage: %s {mmc15|mmc14|wrc|wrc-console}\n", argv[0]);
exit(1);
}
devnode = ertm_usb_by_function(argv[1]);
if (devnode == NULL) {
fprintf(stderr, "could not find function %s\n", argv[1]);
exit(1);
}
printf("%s\n", devnode);
return 0;
}
......@@ -70,16 +70,23 @@ char *ertm_find_usb_port(void)
return sl_cp2108_port[2].devnode;
}
static int __attribute__((__unused__)) udev_main(void)
static char *functions[] = {
"mmc15",
"mmc14",
"wrc",
"wrc-console",
};
char *ertm_usb_by_function(char *func)
{
int i;
int err;
printf("control port is %s\n", ertm_find_usb_port());
err = ertm_search_dongle(SILICON_LABS_ID, CP2108_UART_TO_USB, sl_cp2108_port);
if (err < 0)
return NULL;
for (i = 0; i < 4; i++)
printf("port %d: %s at %s\n",
sl_cp2108_port[i].port,
sl_cp2108_port[i].devnode,
sl_cp2108_port[i].symlink);
return 0;
if (strcmp(func, functions[i]) == 0)
return sl_cp2108_port[i].devnode;
return NULL;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment