-
Notifications
You must be signed in to change notification settings - Fork 0
/
cmds-treppenblink.c
93 lines (72 loc) · 1.69 KB
/
cmds-treppenblink.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <errno.h>
#include <libmicro/can.h>
#include <libmicro/lap.h>
#include "cmds.h"
#include "cmds-treppenblink.h"
void cmd_treppenblink_mode(int argc, char *argv[])
{
pdo_message *msg;
int i;
if (argc != 2) goto argerror;
msg = (pdo_message *)can_buffer_get();
msg->addr_src = 0x00;
msg->addr_dst = 0x25;
msg->port_src = 0x00;
msg->port_dst = 0x0f;
msg->dlc = 1;
// dst
if ( sscanf(argv[1], "%x", &i) != 1)
goto argerror;
msg->cmd = i;
can_transmit((can_message*)msg);
return;
argerror:
printf("modes %s:\n",argv[0]);
printf("\t 0x00 \t - default (blau)\n");
printf("\t 0x01 \t - stop\n");
printf("\t 0x02 \t - Weiss voll\n");
printf("\t 0x03 \t - Weiss halb\n");
printf("\t 0x04 \t - aus\n");
printf("\t 0x05 \t - gruen\n");
printf("\t 0x06 \t - rot\n");
printf("\t 0x07 \t - epi\n");
}
cmd_t treppenblink_cmds[] = {
{ &cmd_treppenblink_mode, "mode", "mode", "switch treppenblink to mode" },
{ NULL, NULL, NULL, NULL }
};
void cmd_treppenblink(int argc, char **argv)
{
char *arg;
cmd_t *cmd;
cmd = treppenblink_cmds;
arg = argv[1];
if (argc > 1)
{
while(cmd->fkt)
{
if (strcmp(arg, cmd->cmd) == 0)
{
(*(cmd->fkt))(argc-1, &(argv[1]));
goto done;
}
cmd++;
}
}
/* show help */
printf( "\nUsage: lapcontrol [OPTIONS] treppenblink <SUBCOMMAND>\n\n" );
printf( "Available Subcommands:\n\n" );
cmd = treppenblink_cmds;
while(cmd->fkt) {
printf( " %-30s %s\n", cmd->sig, cmd->desc );
cmd++;
}
printf("type 'lapcontrol [OPTIONS] treppenblink <SUBCOMMAND> help' for more informations");
printf( "\n" );
done:
return;
}