summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2005-08-25 15:10:54 +0000
committerSascha Hauer <s.hauer@pengutronix.de>2005-08-25 15:10:54 +0000
commit7c17ceb269306a3a3b7a856edf5df276eda1134a (patch)
tree97917d250a4c9081c83068fcd0a9bdaddde0f275
parent1fe44436c7de0efd86716f9e24d1cd505c8981da (diff)
downloadcanutils-7c17ceb269306a3a3b7a856edf5df276eda1134a.tar.gz
added options for rtr and extended messages
git-svn-id: https://iocaste.extern.pengutronix.de/svn/canutils/trunks/canutils-1.0-trunk@37 5fd5a299-6ef2-0310-aa18-8b01d7c39d8c
-rw-r--r--cansend.c24
1 files changed, 22 insertions, 2 deletions
diff --git a/cansend.c b/cansend.c
index fb41e28..9b16042 100644
--- a/cansend.c
+++ b/cansend.c
@@ -30,12 +30,15 @@ void print_usage(char *prg)
"<can-msg> can consist of up to 8 bytes given as a space separated list\n"
"Options:\n"
" -i, --identifier=ID CAN Identifier (default = 1)\n"
+ " -i --rtr send remote request\n"
+ " -e --extended send extended frame\n"
" -f, --family=FAMILY Protocol family (default PF_CAN = %d)\n"
" -t, --type=TYPE Socket type, see man 2 socket (default SOCK_RAW = %d)\n"
" -p, --protocol=PROTO CAN protocol (default CAN_PROTO_RAW = %d)\n"
" -l send message infinite times\n"
" --loop=COUNT send message COUNT times\n"
" -v, --verbose be verbose\n"
+ " -h, --help this help\n"
" --version print version information and exit\n",
prg, PF_CAN, SOCK_RAW, CAN_PROTO_RAW);
}
@@ -49,7 +52,7 @@ int main(int argc, char **argv)
{
int family = PF_CAN, type = SOCK_RAW, proto = CAN_PROTO_RAW;
struct sockaddr_can addr;
- int s, opt, ret, i, dlc = 0;
+ int s, opt, ret, i, dlc = 0, rtr = 0, extended = 0;
struct can_frame frame;
int verbose = 0;
int loopcount = 1, infinite = 0;
@@ -61,6 +64,8 @@ int main(int argc, char **argv)
struct option long_options[] = {
{ "help", no_argument, 0, 'h' },
{ "identifier", required_argument, 0, 'i'},
+ { "rtr", no_argument, 0, 'r'},
+ { "extended", no_argument, 0, 'e'},
{ "family", required_argument, 0, 'f' },
{ "protocol", required_argument, 0, 'p' },
{ "type", required_argument, 0, 't' },
@@ -72,7 +77,7 @@ int main(int argc, char **argv)
frame.can_id = 1;
- while ((opt = getopt_long(argc, argv, "hf:t:p:vi:l", long_options, NULL)) != -1) {
+ while ((opt = getopt_long(argc, argv, "hf:t:p:vi:lre", long_options, NULL)) != -1) {
switch (opt) {
case 'h':
print_usage(basename(argv[0]));
@@ -93,6 +98,7 @@ int main(int argc, char **argv)
case 'v':
verbose = 1;
break;
+
case 'l':
if(optarg)
loopcount = strtoul(optarg, NULL, 0);
@@ -103,6 +109,14 @@ int main(int argc, char **argv)
frame.can_id = strtoul(optarg, NULL, 0);
break;
+ case 'r':
+ rtr = 1;
+ break;
+
+ case 'e':
+ extended = 1;
+ break;
+
case VERSION_OPTION:
printf("cansend %s\n",VERSION);
exit(0);
@@ -154,6 +168,12 @@ int main(int argc, char **argv)
}
frame.can_dlc = dlc;
+ if(rtr)
+ frame.can_id |= CAN_FLAG_RTR;
+
+ if(extended)
+ frame.can_id |= CAN_FLAG_EXTENDED;
+
if(verbose) {
printf("id: %d ",frame.can_id);
printf("dlc: %d\n",frame.can_dlc);