Fixed EOL, indent.
This commit is contained in:
@@ -73,6 +73,7 @@ static uint16_t Timer_Silence(
|
||||
{
|
||||
return SilenceTime;
|
||||
}
|
||||
|
||||
static void Timer_Silence_Reset(
|
||||
void)
|
||||
{
|
||||
|
||||
+59
-120
@@ -68,145 +68,81 @@ static void Init_Object(
|
||||
object_index_to_instance_function index_function,
|
||||
object_name_function name_function)
|
||||
{
|
||||
handler_read_property_object_set(
|
||||
object_type,
|
||||
rp_function,
|
||||
handler_read_property_object_set(object_type, rp_function,
|
||||
object_valid_function);
|
||||
handler_write_property_object_set(
|
||||
object_type,
|
||||
wp_function);
|
||||
handler_read_property_multiple_list_set(
|
||||
object_type,
|
||||
rpm_list_function);
|
||||
Device_Object_Function_Set(
|
||||
object_type,
|
||||
count_function,
|
||||
index_function,
|
||||
handler_write_property_object_set(object_type, wp_function);
|
||||
handler_read_property_multiple_list_set(object_type, rpm_list_function);
|
||||
Device_Object_Function_Set(object_type, count_function, index_function,
|
||||
name_function);
|
||||
}
|
||||
|
||||
static void Init_Objects(void)
|
||||
static void Init_Objects(
|
||||
void)
|
||||
{
|
||||
Device_Init();
|
||||
Init_Object(
|
||||
OBJECT_DEVICE,
|
||||
Device_Property_Lists,
|
||||
Device_Encode_Property_APDU,
|
||||
Device_Valid_Object_Instance_Number,
|
||||
Device_Write_Property,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL);
|
||||
Init_Object(OBJECT_DEVICE, Device_Property_Lists,
|
||||
Device_Encode_Property_APDU, Device_Valid_Object_Instance_Number,
|
||||
Device_Write_Property, NULL, NULL, NULL);
|
||||
|
||||
Analog_Input_Init();
|
||||
Init_Object(
|
||||
OBJECT_ANALOG_INPUT,
|
||||
Analog_Input_Property_Lists,
|
||||
Analog_Input_Encode_Property_APDU,
|
||||
Analog_Input_Valid_Instance,
|
||||
NULL,
|
||||
Analog_Input_Count,
|
||||
Analog_Input_Index_To_Instance,
|
||||
Analog_Input_Name);
|
||||
|
||||
Init_Object(OBJECT_ANALOG_INPUT, Analog_Input_Property_Lists,
|
||||
Analog_Input_Encode_Property_APDU, Analog_Input_Valid_Instance, NULL,
|
||||
Analog_Input_Count, Analog_Input_Index_To_Instance, Analog_Input_Name);
|
||||
|
||||
Analog_Output_Init();
|
||||
Init_Object(
|
||||
OBJECT_ANALOG_OUTPUT,
|
||||
Analog_Output_Property_Lists,
|
||||
Analog_Output_Encode_Property_APDU,
|
||||
Analog_Output_Valid_Instance,
|
||||
Analog_Output_Write_Property,
|
||||
Analog_Output_Count,
|
||||
Analog_Output_Index_To_Instance,
|
||||
Analog_Output_Name);
|
||||
Init_Object(OBJECT_ANALOG_OUTPUT, Analog_Output_Property_Lists,
|
||||
Analog_Output_Encode_Property_APDU, Analog_Output_Valid_Instance,
|
||||
Analog_Output_Write_Property, Analog_Output_Count,
|
||||
Analog_Output_Index_To_Instance, Analog_Output_Name);
|
||||
|
||||
Analog_Value_Init();
|
||||
Init_Object(
|
||||
OBJECT_ANALOG_VALUE,
|
||||
Analog_Value_Property_Lists,
|
||||
Analog_Value_Encode_Property_APDU,
|
||||
Analog_Value_Valid_Instance,
|
||||
Analog_Value_Write_Property,
|
||||
Analog_Value_Count,
|
||||
Analog_Value_Index_To_Instance,
|
||||
Analog_Value_Name);
|
||||
Init_Object(OBJECT_ANALOG_VALUE, Analog_Value_Property_Lists,
|
||||
Analog_Value_Encode_Property_APDU, Analog_Value_Valid_Instance,
|
||||
Analog_Value_Write_Property, Analog_Value_Count,
|
||||
Analog_Value_Index_To_Instance, Analog_Value_Name);
|
||||
|
||||
Binary_Input_Init();
|
||||
Init_Object(
|
||||
OBJECT_BINARY_INPUT,
|
||||
Binary_Input_Property_Lists,
|
||||
Binary_Input_Encode_Property_APDU,
|
||||
Binary_Input_Valid_Instance,
|
||||
NULL,
|
||||
Binary_Input_Count,
|
||||
Binary_Input_Index_To_Instance,
|
||||
Binary_Input_Name);
|
||||
|
||||
Init_Object(OBJECT_BINARY_INPUT, Binary_Input_Property_Lists,
|
||||
Binary_Input_Encode_Property_APDU, Binary_Input_Valid_Instance, NULL,
|
||||
Binary_Input_Count, Binary_Input_Index_To_Instance, Binary_Input_Name);
|
||||
|
||||
Binary_Output_Init();
|
||||
Init_Object(
|
||||
OBJECT_BINARY_OUTPUT,
|
||||
Binary_Output_Property_Lists,
|
||||
Binary_Output_Encode_Property_APDU,
|
||||
Binary_Output_Valid_Instance,
|
||||
Binary_Output_Write_Property,
|
||||
Binary_Output_Count,
|
||||
Binary_Output_Index_To_Instance,
|
||||
Binary_Output_Name);
|
||||
Init_Object(OBJECT_BINARY_OUTPUT, Binary_Output_Property_Lists,
|
||||
Binary_Output_Encode_Property_APDU, Binary_Output_Valid_Instance,
|
||||
Binary_Output_Write_Property, Binary_Output_Count,
|
||||
Binary_Output_Index_To_Instance, Binary_Output_Name);
|
||||
|
||||
Binary_Value_Init();
|
||||
Init_Object(
|
||||
OBJECT_BINARY_VALUE,
|
||||
Binary_Value_Property_Lists,
|
||||
Binary_Value_Encode_Property_APDU,
|
||||
Binary_Value_Valid_Instance,
|
||||
Binary_Value_Write_Property,
|
||||
Binary_Value_Count,
|
||||
Binary_Value_Index_To_Instance,
|
||||
Binary_Value_Name);
|
||||
Init_Object(OBJECT_BINARY_VALUE, Binary_Value_Property_Lists,
|
||||
Binary_Value_Encode_Property_APDU, Binary_Value_Valid_Instance,
|
||||
Binary_Value_Write_Property, Binary_Value_Count,
|
||||
Binary_Value_Index_To_Instance, Binary_Value_Name);
|
||||
|
||||
Life_Safety_Point_Init();
|
||||
Init_Object(
|
||||
OBJECT_LIFE_SAFETY_POINT,
|
||||
Life_Safety_Point_Property_Lists,
|
||||
Init_Object(OBJECT_LIFE_SAFETY_POINT, Life_Safety_Point_Property_Lists,
|
||||
Life_Safety_Point_Encode_Property_APDU,
|
||||
Life_Safety_Point_Valid_Instance,
|
||||
Life_Safety_Point_Write_Property,
|
||||
Life_Safety_Point_Count,
|
||||
Life_Safety_Point_Index_To_Instance,
|
||||
Life_Safety_Point_Valid_Instance, Life_Safety_Point_Write_Property,
|
||||
Life_Safety_Point_Count, Life_Safety_Point_Index_To_Instance,
|
||||
Life_Safety_Point_Name);
|
||||
|
||||
Load_Control_Init();
|
||||
Init_Object(
|
||||
OBJECT_LOAD_CONTROL,
|
||||
Load_Control_Property_Lists,
|
||||
Load_Control_Encode_Property_APDU,
|
||||
Load_Control_Valid_Instance,
|
||||
Load_Control_Write_Property,
|
||||
Load_Control_Count,
|
||||
Load_Control_Index_To_Instance,
|
||||
Load_Control_Name);
|
||||
Init_Object(OBJECT_LOAD_CONTROL, Load_Control_Property_Lists,
|
||||
Load_Control_Encode_Property_APDU, Load_Control_Valid_Instance,
|
||||
Load_Control_Write_Property, Load_Control_Count,
|
||||
Load_Control_Index_To_Instance, Load_Control_Name);
|
||||
|
||||
Multistate_Output_Init();
|
||||
Init_Object(
|
||||
OBJECT_MULTI_STATE_OUTPUT,
|
||||
Multistate_Output_Property_Lists,
|
||||
Init_Object(OBJECT_MULTI_STATE_OUTPUT, Multistate_Output_Property_Lists,
|
||||
Multistate_Output_Encode_Property_APDU,
|
||||
Multistate_Output_Valid_Instance,
|
||||
Multistate_Output_Write_Property,
|
||||
Multistate_Output_Count,
|
||||
Multistate_Output_Index_To_Instance,
|
||||
Multistate_Output_Valid_Instance, Multistate_Output_Write_Property,
|
||||
Multistate_Output_Count, Multistate_Output_Index_To_Instance,
|
||||
Multistate_Output_Name);
|
||||
|
||||
#if defined(BACFILE)
|
||||
bacfile_init();
|
||||
Init_Object(
|
||||
OBJECT_FILE,
|
||||
BACfile_Property_Lists,
|
||||
bacfile_encode_property_apdu,
|
||||
bacfile_valid_instance,
|
||||
bacfile_write_property,
|
||||
bacfile_count,
|
||||
bacfile_index_to_instance,
|
||||
Init_Object(OBJECT_FILE, BACfile_Property_Lists,
|
||||
bacfile_encode_property_apdu, bacfile_valid_instance,
|
||||
bacfile_write_property, bacfile_count, bacfile_index_to_instance,
|
||||
bacfile_name);
|
||||
#endif
|
||||
}
|
||||
@@ -320,10 +256,8 @@ static void Init_Service_Handlers(
|
||||
void)
|
||||
{
|
||||
Device_Init();
|
||||
handler_read_property_object_set(
|
||||
OBJECT_DEVICE,
|
||||
Device_Encode_Property_APDU,
|
||||
Device_Valid_Object_Instance_Number);
|
||||
handler_read_property_object_set(OBJECT_DEVICE,
|
||||
Device_Encode_Property_APDU, Device_Valid_Object_Instance_Number);
|
||||
/* we need to handle who-is to support dynamic device binding */
|
||||
apdu_set_unconfirmed_handler(SERVICE_UNCONFIRMED_WHO_IS, handler_who_is);
|
||||
apdu_set_unconfirmed_handler(SERVICE_UNCONFIRMED_I_AM, LocalIAmHandler);
|
||||
@@ -333,8 +267,10 @@ static void Init_Service_Handlers(
|
||||
apdu_set_unrecognized_service_handler_handler
|
||||
(handler_unrecognized_service);
|
||||
/* we must implement read property - it's required! */
|
||||
apdu_set_confirmed_handler(SERVICE_CONFIRMED_READ_PROPERTY, handler_read_property);
|
||||
apdu_set_confirmed_handler(SERVICE_CONFIRMED_READ_PROP_MULTIPLE, handler_read_property_multiple);
|
||||
apdu_set_confirmed_handler(SERVICE_CONFIRMED_READ_PROPERTY,
|
||||
handler_read_property);
|
||||
apdu_set_confirmed_handler(SERVICE_CONFIRMED_READ_PROP_MULTIPLE,
|
||||
handler_read_property_multiple);
|
||||
/* handle the data coming back from confirmed requests */
|
||||
apdu_set_confirmed_ack_handler(SERVICE_CONFIRMED_READ_PROPERTY,
|
||||
handler_read_property_ack);
|
||||
@@ -377,13 +313,16 @@ static void print_address_cache(
|
||||
}
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
int main(
|
||||
int argc,
|
||||
char *argv[])
|
||||
{
|
||||
BACNET_ADDRESS src = {
|
||||
0}; /* address where message came from */
|
||||
0
|
||||
}; /* address where message came from */
|
||||
uint16_t pdu_len = 0;
|
||||
unsigned timeout = 100; /* milliseconds */
|
||||
BACNET_ADDRESS my_address,
|
||||
broadcast_address;
|
||||
BACNET_ADDRESS my_address, broadcast_address;
|
||||
|
||||
(void) argc;
|
||||
(void) argv;
|
||||
|
||||
@@ -89,11 +89,12 @@ static DWORD RS485_RTSControl = RTS_CONTROL_DISABLE;
|
||||
* ALGORITHM: none
|
||||
* NOTES: none
|
||||
*****************************************************************************/
|
||||
void strupper(char *str)
|
||||
void strupper(
|
||||
char *str)
|
||||
{
|
||||
char *p;
|
||||
for (p = str; *p != '\0'; ++p) {
|
||||
*p = toupper(*p);
|
||||
*p = toupper(*p);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -111,7 +112,7 @@ void RS485_Set_Interface(
|
||||
for CreateFile. The syntax also works for COM ports 1-9. */
|
||||
/* http://support.microsoft.com/kb/115831 */
|
||||
if (ifname) {
|
||||
strupper(ifname);
|
||||
strupper(ifname);
|
||||
if (strncmp("COM", ifname, 3) == 0) {
|
||||
if (strlen(ifname) > 3) {
|
||||
sprintf(RS485_Port_Name, "\\\\.\\COM%i", atoi(ifname + 3));
|
||||
@@ -133,8 +134,8 @@ void RS485_Print_Error(
|
||||
{
|
||||
LPVOID lpMsgBuf;
|
||||
|
||||
FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM,
|
||||
NULL, GetLastError(), MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
|
||||
FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM,
|
||||
NULL, GetLastError(), MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
|
||||
(LPTSTR) & lpMsgBuf, 0, NULL);
|
||||
MessageBox(NULL, lpMsgBuf, "GetLastError", MB_OK | MB_ICONINFORMATION);
|
||||
LocalFree(lpMsgBuf);
|
||||
@@ -398,10 +399,11 @@ static BOOL WINAPI CtrlCHandler(
|
||||
}
|
||||
#endif
|
||||
|
||||
static int ascii_hex_to_int(char ch)
|
||||
static int ascii_hex_to_int(
|
||||
char ch)
|
||||
{
|
||||
int rv = -1;
|
||||
|
||||
|
||||
if ((ch >= '0') && (ch <= '9')) {
|
||||
rv = ch - '0';
|
||||
} else if ((ch >= 'a') && (ch <= 'f')) {
|
||||
@@ -409,7 +411,7 @@ static int ascii_hex_to_int(char ch)
|
||||
} else if ((ch >= 'A') && (ch <= 'F')) {
|
||||
rv = 10 + ch - 'a';
|
||||
}
|
||||
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
@@ -426,7 +428,7 @@ int main(
|
||||
char ch = ' ';
|
||||
int lsb = 0, msb = 0;
|
||||
long my_baud = 38400;
|
||||
uint8_t buffer[501] = {0};
|
||||
uint8_t buffer[501] = { 0 };
|
||||
|
||||
if (argc > 1) {
|
||||
RS485_Set_Interface(argv[1]);
|
||||
@@ -455,15 +457,15 @@ int main(
|
||||
i++;
|
||||
ch = argv[3][i];
|
||||
lsb = ascii_hex_to_int(ch);
|
||||
if (lsb >= 0) {
|
||||
if (lsb >= 0) {
|
||||
buffer[count] = msb << 4 | lsb;
|
||||
} else {
|
||||
} else {
|
||||
buffer[count] = msb;
|
||||
}
|
||||
count++;
|
||||
if (count >= sizeof(buffer)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
count++;
|
||||
if (count >= sizeof(buffer)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
RS485_Send_Frame(NULL, buffer, count);
|
||||
@@ -489,4 +491,3 @@ int main(
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
@@ -64,8 +64,9 @@ extern "C" {
|
||||
void);
|
||||
bool RS485_Set_Baud_Rate(
|
||||
uint32_t baud);
|
||||
|
||||
void RS485_Print_Error(void);
|
||||
|
||||
void RS485_Print_Error(
|
||||
void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
@@ -87,6 +87,7 @@ static uint16_t Timer_Silence(
|
||||
{
|
||||
return SilenceTime;
|
||||
}
|
||||
|
||||
static void Timer_Silence_Reset(
|
||||
void)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user