-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.cc
92 lines (83 loc) · 1.77 KB
/
main.cc
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
92
#include <parson/parson.h>
#include "DeviceInterface.hh"
bool creatjson(char* buf)
{
if (!buf)
{
return false;
}
JSON_Value *root;
JSON_Object *object;
bool ret = false;
char* data;
bool onoff;
int volume;
int brightness;
root = json_value_init_object();
if (!root) {
return false;
}
object = json_object(root);
if (!object) {
goto end;
}
//json_object_set_string(object, "Program", "/home/liaoxw/7g_box/flask-svr/screen-svr/libInfoScreen/4028b18a67780f07016927d29e6d00ad");
json_object_set_number(object, "OnOff", 1);
data = json_serialize_to_string_pretty(root);
if (data) {
snprintf(buf, 128, "%s", data);
ret = true;
}
end:
json_value_free(root);
return ret;
}
bool creatjson1(char* buf)
{
if (!buf)
{
return false;
}
JSON_Value *root;
JSON_Object *object;
bool ret = false;
char* data;
bool onoff;
int volume;
int brightness;
root = json_value_init_object();
if (!root) {
return false;
}
object = json_object(root);
if (!object) {
goto end;
}
json_object_set_string(object, "ip", "192.168.53.42");
data = json_serialize_to_string_pretty(root);
if (data) {
snprintf(buf, 128, "%s", data);
ret = true;
}
end:
json_value_free(root);
return ret;
}
int main()
{
char input[128];
char output[256];
char dev[256];
int ret = -1;
creatjson(input);
creatjson1(dev);
printf("dev:%s\n", dev);
void* handle = Open(dev, 2,1);
if (handle) {
printf("input:%s\n", input);
ret = Ioctl(handle, 2,5,input, output);
printf("ret:%d\n",ret);
printf("put:%s\n", output);
}
return 1;
}