Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
336 | f9daq | 1 | /* |
2 | * main.c |
||
3 | * |
||
4 | * Created on: 18. dec. 2018 |
||
5 | * Author: Domen |
||
6 | */ |
||
7 | |||
8 | /* MAIN PROGRAM */ |
||
9 | |||
10 | #include "data_handling.h" |
||
11 | #include "server.h" |
||
12 | |||
13 | |||
14 | |||
15 | HW_system system_data = {0,0,0,0,0,0,0,0,0,0}; |
||
16 | volatile const HW_system system_data_init = {0,0,0,0,0,0,0,0,0,0}; |
||
17 | |||
18 | |||
19 | int main(void) |
||
20 | { |
||
21 | |||
22 | int server_info[2]; //sock_server in sock_client: PC_client; //ID PC clienta |
||
23 | uint32_t *virt_addr_ptr; // virtualni naslov, kjer so podatki v HW |
||
24 | static uint8_t data_status; // flag, ki pove, da se je vpis HW podatkov v strukturo ze vsaj 1x izvedel |
||
25 | |||
26 | |||
27 | while(1) |
||
28 | { |
||
29 | server_info[0] = 0; // sock_server |
||
30 | server_info[1] = 0; //sock_client |
||
31 | |||
32 | //PC_client = 0; |
||
33 | data_status = 0; |
||
34 | |||
35 | //SERVER AND HARDWARE INIT |
||
36 | Server_init(server_info); |
||
37 | virt_addr_ptr = HW_init(); |
||
38 | |||
39 | |||
40 | // DATA HANDLING |
||
41 | while(1) |
||
42 | { |
||
43 | Server_comm(server_info, &system_data, data_status); |
||
44 | data_status = HW_comm(&system_data, virt_addr_ptr); |
||
45 | |||
46 | if (system_data.disconnect_flag == 1) |
||
47 | { |
||
48 | //system_data.disconnect_flag = 0; //ponastavi flag |
||
49 | system_data = system_data_init; |
||
50 | printf("Server disconnected\n!"); |
||
51 | break; |
||
52 | } |
||
53 | //sleep(1); |
||
54 | } |
||
55 | |||
56 | } |
||
57 | |||
58 | } |
||
59 | |||
60 | |||
61 |