-
Notifications
You must be signed in to change notification settings - Fork 0
/
throttle.c
49 lines (39 loc) · 1.22 KB
/
throttle.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
/*
* throttle.c
*/
#include <stdio.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/neutrino.h>
#include <sys/iofunc.h>
#include <sys/dispatch.h>
#include "engine.h" // defines messages between client and server
int main(int argc, char **argv) {
throttle_toggle_msg_t msg;
int server_coid, status;
char return_status[256];
int pressure;
if (argc != 2){
printf("Error: Must have two arguments\n");
exit(EXIT_FAILURE);
}
pressure = atoi(argv[1]);
printf("throttle.c now attempting to connect to engine.c\n");
/* find our server to get a coid*/
if ((server_coid = name_open(SERVER_NAME, 0)) == -1) {
return EXIT_FAILURE;
}
printf("throttle.c successfully connected to engine.c\n");
/* send a get message to the server to get a shared memory handle from the server */
msg.type = THROTTLE_TOGGLE;
msg.pressure = pressure;
status = MsgSend(server_coid, &msg, sizeof(msg), return_status, sizeof(return_status));
printf("throttle.c returned: %s\n", return_status);
if (status == -1) {
fprintf(stderr, "Error during MsgSend\n");
perror(NULL);
exit(EXIT_FAILURE);
}
return EXIT_SUCCESS;
}