Revision 343
changed the brace style and reformatted the files
wl_error_group.c | ||
---|---|---|
42 | 42 |
|
43 | 43 |
void wl_error_response_receive(int frame, int received); |
44 | 44 |
void wl_error_handle_receive(char type, int source, unsigned char* packet, |
45 |
int length);
|
|
45 |
int length);
|
|
46 | 46 |
|
47 | 47 |
PacketGroupHandler wl_error_handler = |
48 |
{WL_ERROR_GROUP, NULL,
|
|
49 |
wl_error_response_receive, wl_error_handle_receive, NULL};
|
|
48 |
{WL_ERROR_GROUP, NULL,
|
|
49 |
wl_error_response_receive, wl_error_handle_receive, NULL};
|
|
50 | 50 |
|
51 |
void wl_error_response_receive(int frame, int received) |
|
52 |
{ |
|
53 |
WL_DEBUG_PRINT("Response received.\r\n"); |
|
54 |
if (!received) |
|
55 |
{ |
|
56 |
WL_DEBUG_PRINT("FAILED.\r\n"); |
|
57 |
} |
|
51 |
void wl_error_response_receive(int frame, int received) { |
|
52 |
WL_DEBUG_PRINT("Response received.\r\n"); |
|
53 |
if (!received) { |
|
54 |
WL_DEBUG_PRINT("FAILED.\r\n"); |
|
55 |
} |
|
58 | 56 |
} |
59 | 57 |
/** |
60 | 58 |
* Register this packet group with the wireless library. |
61 | 59 |
* This function must be called before any other wl_error |
62 | 60 |
* function. |
63 | 61 |
**/ |
64 |
void wl_error_register(void) |
|
65 |
{ |
|
66 |
wl_register_packet_group(&wl_error_handler); |
|
62 |
void wl_error_register(void) { |
|
63 |
wl_register_packet_group(&wl_error_handler); |
|
67 | 64 |
} |
68 | 65 |
|
69 | 66 |
/** |
... | ... | |
72 | 69 |
* |
73 | 70 |
* @see wl_error_register |
74 | 71 |
**/ |
75 |
void wl_error_unregister(void) |
|
76 |
{ |
|
77 |
wl_unregister_packet_group(&wl_error_handler); |
|
72 |
void wl_error_unregister(void) { |
|
73 |
wl_unregister_packet_group(&wl_error_handler); |
|
78 | 74 |
} |
79 | 75 |
|
80 | 76 |
/** |
... | ... | |
86 | 82 |
* @param length the length in bytes of the packet |
87 | 83 |
**/ |
88 | 84 |
void wl_error_handle_receive(char type, int source, unsigned char* packet, |
89 |
int length) |
|
90 |
{ |
|
91 |
switch (type) |
|
92 |
{ |
|
93 |
case WL_ERROR_STRING_TYPE: |
|
94 |
if (packet[length - 1] != 0) |
|
95 |
{ |
|
96 |
WL_DEBUG_PRINT( |
|
97 |
"Error packet string should be null terminated.\r\n"); |
|
98 |
break; |
|
99 |
} |
|
100 |
WL_DEBUG_PRINT("Error packet received from robot "); |
|
101 |
WL_DEBUG_PRINT_INT(source); |
|
102 |
WL_DEBUG_PRINT(":\r\n"); |
|
103 |
WL_DEBUG_PRINT((char*)packet); |
|
104 |
WL_DEBUG_PRINT("\r\n"); |
|
105 |
break; |
|
106 |
default: |
|
107 |
WL_DEBUG_PRINT("Error packet of unknown type received.\r\n"); |
|
108 |
break; |
|
109 |
} |
|
85 |
int length) { |
|
86 |
switch (type) { |
|
87 |
case WL_ERROR_STRING_TYPE: |
|
88 |
if (packet[length - 1] != 0) { |
|
89 |
WL_DEBUG_PRINT( |
|
90 |
"Error packet string should be null terminated.\r\n"); |
|
91 |
break; |
|
92 |
} |
|
93 |
WL_DEBUG_PRINT("Error packet received from robot "); |
|
94 |
WL_DEBUG_PRINT_INT(source); |
|
95 |
WL_DEBUG_PRINT(":\r\n"); |
|
96 |
WL_DEBUG_PRINT((char*)packet); |
|
97 |
WL_DEBUG_PRINT("\r\n"); |
|
98 |
break; |
|
99 |
default: |
|
100 |
WL_DEBUG_PRINT("Error packet of unknown type received.\r\n"); |
|
101 |
break; |
|
102 |
} |
|
110 | 103 |
} |
111 | 104 |
|
112 | 105 |
/** |
... | ... | |
114 | 107 |
* |
115 | 108 |
* @param str the error message to send |
116 | 109 |
**/ |
117 |
void wl_error_send_string(char* str) |
|
118 |
{ |
|
119 |
wl_send_global_packet(WL_ERROR_GROUP, WL_ERROR_STRING_TYPE, |
|
120 |
str, strlen(str) + 1, 1); |
|
110 |
void wl_error_send_string(char* str) { |
|
111 |
wl_send_global_packet(WL_ERROR_GROUP, WL_ERROR_STRING_TYPE, |
|
112 |
str, strlen(str) + 1, 1); |
|
121 | 113 |
} |
122 | 114 |
|
Also available in: Unified diff