Fixed EOL, indent.

This commit is contained in:
skarg
2009-10-24 17:02:59 +00:00
parent 857d0c185d
commit c04e69da8c
118 changed files with 2633 additions and 2629 deletions
+2 -2
View File
@@ -313,8 +313,8 @@ bool Analog_Value_Write_Property(
(value.type.Real >= 0.0) && (value.type.Real <= 100.0)) {
level = (uint8_t) value.type.Real;
object_index =
Analog_Value_Instance_To_Index(wp_data->
object_instance);
Analog_Value_Instance_To_Index
(wp_data->object_instance);
priority--;
Present_Value[object_index] = level;
/* Note: you could set the physical output here if we
+2 -2
View File
@@ -225,8 +225,8 @@ bool Binary_Value_Write_Property(
(value.type.Enumerated <= MAX_BINARY_PV)) {
level = value.type.Enumerated;
object_index =
Binary_Value_Instance_To_Index(wp_data->
object_instance);
Binary_Value_Instance_To_Index
(wp_data->object_instance);
priority--;
/* NOTE: this Binary value has no priority array */
Present_Value[object_index] = level;
+2 -2
View File
@@ -492,8 +492,8 @@ bool Device_Write_Property(
case PROP_OBJECT_IDENTIFIER:
if (value.tag == BACNET_APPLICATION_TAG_OBJECT_ID) {
if ((value.type.Object_Id.type == OBJECT_DEVICE) &&
(Device_Set_Object_Instance_Number(value.type.Object_Id.
instance))) {
(Device_Set_Object_Instance_Number(value.type.
Object_Id.instance))) {
/* we could send an I-Am broadcast to let the world know */
status = true;
} else {
+2 -3
View File
@@ -66,9 +66,8 @@ int Encode_Property_APDU(
case OBJECT_DEVICE:
if (Device_Valid_Object_Instance_Number(object_instance)) {
apdu_len =
Device_Encode_Property_APDU(&apdu[0],
object_instance, property,
array_index, error_class, error_code);
Device_Encode_Property_APDU(&apdu[0], object_instance,
property, array_index, error_class, error_code);
}
break;
case OBJECT_ANALOG_INPUT:
+2 -1
View File
@@ -143,7 +143,8 @@ static inline void bacnet_init(
#endif
Device_Set_Object_Instance_Number(22222);
/* set up our confirmed service unrecognized service handler - required! */
apdu_set_unrecognized_service_handler_handler(handler_unrecognized_service);
apdu_set_unrecognized_service_handler_handler
(handler_unrecognized_service);
/* we need to handle who-is to support dynamic device binding */
apdu_set_unconfirmed_handler(SERVICE_UNCONFIRMED_WHO_IS, handler_who_is);
/* Set the handlers for any confirmed services that we support. */
+2 -2
View File
@@ -200,8 +200,8 @@ bool Binary_Value_Write_Property(
if ((value.type.Enumerated == BINARY_ACTIVE) ||
(value.type.Enumerated == BINARY_INACTIVE)) {
object_index =
Binary_Value_Instance_To_Index(wp_data->
object_instance);
Binary_Value_Instance_To_Index
(wp_data->object_instance);
/* NOTE: this Binary value has no priority array */
Present_Value[object_index] =
(BACNET_BINARY_PV) value.type.Enumerated;
+2 -2
View File
@@ -364,8 +364,8 @@ bool Device_Write_Property(
case PROP_OBJECT_IDENTIFIER:
if (value.tag == BACNET_APPLICATION_TAG_OBJECT_ID) {
if ((value.type.Object_Id.type == OBJECT_DEVICE) &&
(Device_Set_Object_Instance_Number(value.type.Object_Id.
instance))) {
(Device_Set_Object_Instance_Number(value.type.
Object_Id.instance))) {
/* we could send an I-Am broadcast to let the world know */
status = true;
} else {
+2 -4
View File
@@ -57,10 +57,8 @@ int Encode_Property_APDU(
if (Device_Valid_Object_Instance_Number(rp_data->object_instance)) {
apdu_len =
Device_Encode_Property_APDU(&apdu[0],
rp_data->object_instance,
rp_data->object_property,
rp_data->array_index,
error_class, error_code);
rp_data->object_instance, rp_data->object_property,
rp_data->array_index, error_class, error_code);
}
break;
case OBJECT_ANALOG_VALUE:
+2 -2
View File
@@ -200,8 +200,8 @@ bool Binary_Value_Write_Property(
if ((value.type.Enumerated == BINARY_ACTIVE) ||
(value.type.Enumerated == BINARY_INACTIVE)) {
object_index =
Binary_Value_Instance_To_Index(wp_data->
object_instance);
Binary_Value_Instance_To_Index
(wp_data->object_instance);
/* NOTE: this Binary value has no priority array */
Present_Value[object_index] =
(BACNET_BINARY_PV) value.type.Enumerated;
+2 -4
View File
@@ -61,10 +61,8 @@ int Encode_Property_APDU(
if (Device_Valid_Object_Instance_Number(rp_data->object_instance)) {
apdu_len =
Device_Encode_Property_APDU(&apdu[0],
rp_data->object_instance,
rp_data->object_property,
rp_data->array_index,
error_class, error_code);
rp_data->object_instance, rp_data->object_property,
rp_data->array_index, error_class, error_code);
}
break;
#if MAX_ANALOG_VALUES
+1 -1
View File
@@ -112,7 +112,7 @@ uint32_t Analog_Input_Index_To_Instance(
char *Analog_Input_Name(
uint32_t object_instance)
{
static char text_string[32]; /* okay for single thread */
static char text_string[32]; /* okay for single thread */
if (object_instance < MAX_ANALOG_INPUTS) {
sprintf(text_string, "AI-%lu", object_instance);
+1 -1
View File
@@ -163,7 +163,7 @@ bool Binary_Input_Present_Value_Set(
char *Binary_Input_Name(
uint32_t object_instance)
{
static char text_string[32]; /* okay for single thread */
static char text_string[32]; /* okay for single thread */
if (object_instance < MAX_BINARY_INPUTS) {
sprintf(text_string, "BI-%lu", object_instance);
+1 -1
View File
@@ -240,7 +240,7 @@ void Binary_Output_Level_Sync(
char *Binary_Output_Name(
uint32_t object_instance)
{
static char text_string[32]; /* okay for single thread */
static char text_string[32]; /* okay for single thread */
if (object_instance < MAX_BINARY_OUTPUTS) {
sprintf(text_string, "BO-%lu", object_instance);
+10 -10
View File
@@ -120,7 +120,7 @@ void Device_Init(
void)
{
Reinitialize_State = REINITIALIZED_STATE_IDLE;
dcc_set_status_duration(COMMUNICATION_ENABLE, 0);
/* Get the data from the eeprom */
eeprom_bytes_read(NV_EEPROM_DEVICE_0, (uint8_t *) & Object_Instance_Number,
@@ -143,8 +143,8 @@ void Device_Init(
eeprom_bytes_write(NV_EEPROM_DEVICE_NAME_ENCODING,
&Object_Name_Encoding, 1);
sprintf(Object_Name, "DEVICE-%lu", Object_Instance_Number);
eeprom_bytes_write(NV_EEPROM_DEVICE_NAME_0, (uint8_t *) & Object_Name[0],
NV_EEPROM_DEVICE_NAME_SIZE);
eeprom_bytes_write(NV_EEPROM_DEVICE_NAME_0,
(uint8_t *) & Object_Name[0], NV_EEPROM_DEVICE_NAME_SIZE);
Object_Name_Length = strlen(Object_Name);
eeprom_bytes_write(NV_EEPROM_DEVICE_NAME_LENGTH, &Object_Name_Length,
1);
@@ -506,8 +506,8 @@ int Device_Encode_Property_APDU(
apdu_len = encode_application_unsigned(&apdu[0], stack_unused());
break;
case 9600:
apdu_len = encode_application_unsigned(&apdu[0],
rs485_baud_rate());
apdu_len =
encode_application_unsigned(&apdu[0], rs485_baud_rate());
break;
default:
*error_class = ERROR_CLASS_PROPERTY;
@@ -543,8 +543,8 @@ bool Device_Write_Property(
case PROP_OBJECT_IDENTIFIER:
if (value.tag == BACNET_APPLICATION_TAG_OBJECT_ID) {
if ((value.type.Object_Id.type == OBJECT_DEVICE) &&
(Device_Set_Object_Instance_Number(value.type.Object_Id.
instance))) {
(Device_Set_Object_Instance_Number(value.type.
Object_Id.instance))) {
/* we could send an I-Am broadcast to let the world know */
status = true;
} else {
@@ -591,7 +591,7 @@ bool Device_Write_Property(
characterstring_length(&value.type.Character_String);
if (length < 1) {
*error_class = ERROR_CLASS_PROPERTY;
*error_code = ERROR_CODE_VALUE_OUT_OF_RANGE;
*error_code = ERROR_CODE_VALUE_OUT_OF_RANGE;
} else if (length < NV_EEPROM_DEVICE_NAME_SIZE) {
uint8_t encoding =
characterstring_encoding(&value.type.Character_String);
@@ -605,8 +605,8 @@ bool Device_Write_Property(
eeprom_bytes_write(NV_EEPROM_DEVICE_NAME_LENGTH,
&Object_Name_Length, 1);
pCharString =
characterstring_value(&value.type.
Character_String);
characterstring_value(&value.
type.Character_String);
for (i = 0; i < Object_Name_Length; i++) {
Object_Name[i] = pCharString[i];
}
+9 -6
View File
@@ -670,7 +670,8 @@ static void MSTP_Receive_Frame_FSM(
#ifdef MSTP_DEBUG_STATES
static MSTP_MASTER_STATE Master_State_Log[128];
static unsigned master_state_log_index = 0;
void log_master_state(MSTP_MASTER_STATE state)
void log_master_state(
MSTP_MASTER_STATE state)
{
Master_State_Log[master_state_log_index] = state;
master_state_log_index++;
@@ -679,7 +680,7 @@ void log_master_state(MSTP_MASTER_STATE state)
}
}
#else
#define log_master_state(n) (void)n;
#define log_master_state(n) (void)n;
#endif
/* returns true if we need to transition immediately */
@@ -1362,7 +1363,8 @@ void dlmstp_get_broadcast_address(
return;
}
char *dlmstp_receive_state_text(void)
char *dlmstp_receive_state_text(
void)
{
switch (Receive_State) {
case MSTP_RECEIVE_STATE_IDLE:
@@ -1376,11 +1378,12 @@ char *dlmstp_receive_state_text(void)
default:
break;
}
return "unknown";
}
char *dlmstp_master_state_text(void)
char *dlmstp_master_state_text(
void)
{
switch (Master_State) {
case MSTP_MASTER_STATE_INITIALIZE:
@@ -1404,6 +1407,6 @@ char *dlmstp_master_state_text(void)
default:
break;
}
return "unknown";
}
+45 -48
View File
@@ -29,19 +29,19 @@
FUSES = {
/* == LOW FUSE or LFUSE settings == */
/* CKSEL3..0- Clock Select Configuration
CKSEL3 CKSEL2 CKSEL1 CKSEL0 Description
1 1 1 x 1111-1000=Low Power Crystal Oscillator
0 1 1 x 0111-0110=Full Swing Crystal Oscillator
0 1 0 x 0101-0100=Low Frequency Crystal Oscillator
0 0 1 1 Internal 128kHz RC Oscillator
0 0 1 0 Calibrated Internal RC Oscillator
0 0 0 0 External Clock]
CKSEL3 CKSEL2 CKSEL1 CKSEL0 Description
1 1 1 x 1111-1000=Low Power Crystal Oscillator
0 1 1 x 0111-0110=Full Swing Crystal Oscillator
0 1 0 x 0101-0100=Low Frequency Crystal Oscillator
0 0 1 1 Internal 128kHz RC Oscillator
0 0 1 0 Calibrated Internal RC Oscillator
0 0 0 0 External Clock]
SUT1..0 - Clock Start Up Time selection
If CKSEL0=0, then SUT1..0 is 14CK+: 00=4.1ms,01=65ms,10=BOD,11=4.1ms
If CKSEL0=1, then SUT1..0 is 14CK+: 00=65ms,01=BOD,10=4.1ms,11=65ms
BOD means wait until internal Brown Out Detect Voltage is sufficient.
*/
SUT1..0 - Clock Start Up Time selection
If CKSEL0=0, then SUT1..0 is 14CK+: 00=4.1ms,01=65ms,10=BOD,11=4.1ms
If CKSEL0=1, then SUT1..0 is 14CK+: 00=65ms,01=BOD,10=4.1ms,11=65ms
BOD means wait until internal Brown Out Detect Voltage is sufficient.
*/
/* CKOUT: clock output on CKOUT pin */
/* CKDIV8: divide clock by 8 */
/* External Ceramic Resonator - configuration */
@@ -53,42 +53,39 @@ FUSES = {
any fuses listed below are cleared fuses,
or are CKSEL or SUT bits that are zero. */
.low = (FUSE_CKSEL3 & FUSE_SUT1),
/* == HIGH FUSE or HFUSE settings == */
/* BOOTRST: Enable Bootloader Reset Vector */
/* EESAVE: Enable preserve EEPROM on Chip Erase */
/* WDTON: Enable watchdog timer always on */
/* SPIEN: Enable Serial Program and Data Downloading */
/* JTAGEN: Enable JTAG */
/* OCDEN: Enable OCD */
/* BOOTSZ configuration:
BOOTSZ1 BOOTSZ0 Boot Size
------- ------- ---------
1 1 512
1 0 1024
0 1 2048
0 0 4096
*/
/* note: fuses are enabled by clearing the bit, so
any fuses listed below are cleared fuses,
or are BOOTSZ bits that are zero. */
.high =
(FUSE_BOOTSZ1 & FUSE_EESAVE & FUSE_SPIEN & FUSE_JTAGEN),
/* == EXTENDED FUSE or EFUSE settings == */
/* BODLEVEL configuration
BODLEVEL2 BODLEVEL1 BODLEVEL0 Voltage
--------- --------- --------- --------
1 1 1 disabled
1 1 0 1.8V
1 0 1 2.7V
1 0 0 4.3V
*/
/* note: fuses are enabled by clearing the bit, so
any fuses listed below are cleared fuses,
or are BODLEVEL bits that are zero. */
/* Brown-out detection VCC=4.3V */
.extended = (FUSE_BODLEVEL1 & FUSE_BODLEVEL0)
/* == HIGH FUSE or HFUSE settings == */
/* BOOTRST: Enable Bootloader Reset Vector */
/* EESAVE: Enable preserve EEPROM on Chip Erase */
/* WDTON: Enable watchdog timer always on */
/* SPIEN: Enable Serial Program and Data Downloading */
/* JTAGEN: Enable JTAG */
/* OCDEN: Enable OCD */
/* BOOTSZ configuration:
BOOTSZ1 BOOTSZ0 Boot Size
------- ------- ---------
1 1 512
1 0 1024
0 1 2048
0 0 4096
*/
/* note: fuses are enabled by clearing the bit, so
any fuses listed below are cleared fuses,
or are BOOTSZ bits that are zero. */
.high = (FUSE_BOOTSZ1 & FUSE_EESAVE & FUSE_SPIEN & FUSE_JTAGEN),
/* == EXTENDED FUSE or EFUSE settings == */
/* BODLEVEL configuration
BODLEVEL2 BODLEVEL1 BODLEVEL0 Voltage
--------- --------- --------- --------
1 1 1 disabled
1 1 0 1.8V
1 0 1 2.7V
1 0 0 4.3V
*/
/* note: fuses are enabled by clearing the bit, so
any fuses listed below are cleared fuses,
or are BODLEVEL bits that are zero. */
/* Brown-out detection VCC=4.3V */
.extended = (FUSE_BODLEVEL1 & FUSE_BODLEVEL0)
};
/* AVR lock bits - unlocked */
+2 -3
View File
@@ -66,9 +66,8 @@ int Encode_Property_APDU(
case OBJECT_DEVICE:
if (Device_Valid_Object_Instance_Number(object_instance)) {
apdu_len =
Device_Encode_Property_APDU(&apdu[0],
object_instance, property,
array_index, error_class, error_code);
Device_Encode_Property_APDU(&apdu[0], object_instance,
property, array_index, error_class, error_code);
}
break;
case OBJECT_ANALOG_INPUT:
+1 -1
View File
@@ -59,5 +59,5 @@ void init(
PORTD = 0;
/* Configure the watchdog timer - Disabled for testing */
/* wdt_enable(WDTO_2S); */
wdt_disable();
wdt_disable();
}
+15 -12
View File
@@ -98,7 +98,8 @@ static void bacnet_init(
Analog_Value_Init();
/* set up our confirmed service unrecognized service handler - required! */
apdu_set_unrecognized_service_handler_handler(handler_unrecognized_service);
apdu_set_unrecognized_service_handler_handler
(handler_unrecognized_service);
/* we need to handle who-is to support dynamic device binding */
apdu_set_unconfirmed_handler(SERVICE_UNCONFIRMED_WHO_IS, handler_who_is);
/* Set the handlers for any confirmed services that we support. */
@@ -190,7 +191,7 @@ void test_task(
buffer[12] = (MSTP_MAC_Address & BIT4) ? '1' : '0';
buffer[13] = (MSTP_MAC_Address & BIT5) ? '1' : '0';
buffer[14] = (MSTP_MAC_Address & BIT6) ? '1' : '0';
serial_bytes_send((uint8_t *)buffer, nbytes);
serial_bytes_send((uint8_t *) buffer, nbytes);
}
if (serial_byte_get(&data_register)) {
/* echo the character */
@@ -215,21 +216,23 @@ void test_task(
}
if (data_register == 'm') {
sprintf(buffer, "->Master State: ");
nbytes = (uint8_t)strlen(buffer);
serial_bytes_send((uint8_t *)buffer, nbytes);
extern char *dlmstp_master_state_text(void);
nbytes = (uint8_t) strlen(buffer);
serial_bytes_send((uint8_t *) buffer, nbytes);
extern char *dlmstp_master_state_text(
void);
pBuffer = dlmstp_master_state_text();
nbytes = (uint8_t)strlen(pBuffer);
serial_bytes_send((uint8_t *)pBuffer, nbytes);
nbytes = (uint8_t) strlen(pBuffer);
serial_bytes_send((uint8_t *) pBuffer, nbytes);
}
if (data_register == 'r') {
sprintf(buffer, "->Receive State: ");
nbytes = (uint8_t)strlen(buffer);
serial_bytes_send((uint8_t *)buffer, nbytes);
extern char *dlmstp_receive_state_text(void);
nbytes = (uint8_t) strlen(buffer);
serial_bytes_send((uint8_t *) buffer, nbytes);
extern char *dlmstp_receive_state_text(
void);
pBuffer = dlmstp_receive_state_text();
nbytes = (uint8_t)strlen(pBuffer);
serial_bytes_send((uint8_t *)pBuffer, nbytes);
nbytes = (uint8_t) strlen(pBuffer);
serial_bytes_send((uint8_t *) pBuffer, nbytes);
}
serial_byte_send('\r');
serial_byte_send('\n');
+1
View File
@@ -73,6 +73,7 @@ static uint16_t Timer_Silence(
{
return SilenceTime;
}
static void Timer_Silence_Reset(
void)
{
+2 -4
View File
@@ -163,10 +163,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);
+1
View File
@@ -65,6 +65,7 @@ static uint16_t Timer_Silence(
{
return SilenceTime;
}
static void Timer_Silence_Reset(
void)
{
+1
View File
@@ -75,6 +75,7 @@ static uint16_t Timer_Silence(
{
return SilenceTime;
}
static void Timer_Silence_Reset(
void)
{
+2 -2
View File
@@ -310,8 +310,8 @@ bool Analog_Value_Write_Property(
(value.type.Real >= 0.0) && (value.type.Real <= 100.0)) {
level = (uint8_t) value.type.Real;
object_index =
Analog_Value_Instance_To_Index(wp_data->
object_instance);
Analog_Value_Instance_To_Index
(wp_data->object_instance);
priority--;
Present_Value[object_index] = level;
/* Note: you could set the physical output here if we
+2 -2
View File
@@ -226,8 +226,8 @@ bool Binary_Value_Write_Property(
(value.type.Enumerated <= MAX_BINARY_PV)) {
level = value.type.Enumerated;
object_index =
Binary_Value_Instance_To_Index(wp_data->
object_instance);
Binary_Value_Instance_To_Index
(wp_data->object_instance);
priority--;
/* NOTE: this Binary value has no priority array */
Present_Value[object_index] = level;
+2 -2
View File
@@ -504,8 +504,8 @@ bool Device_Write_Property(
case PROP_OBJECT_IDENTIFIER:
if (value.tag == BACNET_APPLICATION_TAG_OBJECT_ID) {
if ((value.type.Object_Id.type == OBJECT_DEVICE) &&
(Device_Set_Object_Instance_Number(value.type.Object_Id.
instance))) {
(Device_Set_Object_Instance_Number(value.type.
Object_Id.instance))) {
/* we could send an I-Am broadcast to let the world know */
status = true;
} else {
+2 -3
View File
@@ -93,9 +93,8 @@ void handler_read_property(
if (Device_Valid_Object_Instance_Number(data.object_instance)) {
len =
Device_Encode_Property_APDU(&Temp_Buf[0],
data.object_instance,
data.object_property, data.array_index, &error_class,
&error_code);
data.object_instance, data.object_property,
data.array_index, &error_class, &error_code);
if (len >= 0) {
/* encode the APDU portion of the packet */
data.application_data = &Temp_Buf[0];
+3
View File
@@ -68,12 +68,15 @@ RTFDevice RTFDeviceList[] = {
#define MAXTYPES 32
RTW32Handle RTHandleTable[MAXHANDLES] = { {0} };
int RTHandleCount = MAXHANDLES;
RTW32Object RTObjectTable[MAXOBJECTS] = { {0} };
int RTObjectCount = MAXOBJECTS;
RTW32Types RTTypeTable[MAXTYPES] = { {0} };
int RTTypeCount = MAXTYPES;
#if 0
+1
View File
@@ -73,6 +73,7 @@ static uint16_t Timer_Silence(
{
return SilenceTime;
}
static void Timer_Silence_Reset(
void)
{
+59 -120
View File
@@ -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;
+18 -17
View File
@@ -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
+3 -2
View File
@@ -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
}
+1
View File
@@ -87,6 +87,7 @@ static uint16_t Timer_Silence(
{
return SilenceTime;
}
static void Timer_Silence_Reset(
void)
{