Added MS/TP debugging to serial port test.
This commit is contained in:
@@ -49,7 +49,7 @@
|
||||
The properties that are constant can be hard coded
|
||||
into the read-property encoding. */
|
||||
static uint32_t Object_Instance_Number;
|
||||
static uint8_t Object_Name[NV_EEPROM_DEVICE_NAME_SIZE];
|
||||
static char Object_Name[NV_EEPROM_DEVICE_NAME_SIZE];
|
||||
static uint8_t Object_Name_Encoding;
|
||||
static uint8_t Object_Name_Length;
|
||||
static BACNET_DEVICE_STATUS System_Status = STATUS_OPERATIONAL;
|
||||
@@ -506,7 +506,7 @@ int Device_Encode_Property_APDU(
|
||||
break;
|
||||
case 9600:
|
||||
apdu_len = encode_application_unsigned(&apdu[0],
|
||||
rs485_baud_rate());
|
||||
rs485_baud_rate());
|
||||
break;
|
||||
default:
|
||||
*error_class = ERROR_CLASS_PROPERTY;
|
||||
|
||||
@@ -1341,3 +1341,49 @@ void dlmstp_get_broadcast_address(
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
char *dlmstp_receive_state_text(void)
|
||||
{
|
||||
switch (Receive_State) {
|
||||
case MSTP_RECEIVE_STATE_IDLE:
|
||||
return "idle";
|
||||
case MSTP_RECEIVE_STATE_PREAMBLE:
|
||||
return "preamble";
|
||||
case MSTP_RECEIVE_STATE_HEADER:
|
||||
return "header";
|
||||
case MSTP_RECEIVE_STATE_DATA:
|
||||
return "data";
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return "unknown";
|
||||
}
|
||||
|
||||
char *dlmstp_master_state_text(void)
|
||||
{
|
||||
switch (Master_State) {
|
||||
case MSTP_MASTER_STATE_INITIALIZE:
|
||||
return "init";
|
||||
case MSTP_MASTER_STATE_IDLE:
|
||||
return "idle";
|
||||
case MSTP_MASTER_STATE_USE_TOKEN:
|
||||
return "use-token";
|
||||
case MSTP_MASTER_STATE_WAIT_FOR_REPLY:
|
||||
return "wait-for-reply";
|
||||
case MSTP_MASTER_STATE_DONE_WITH_TOKEN:
|
||||
return "done-with-token";
|
||||
case MSTP_MASTER_STATE_PASS_TOKEN:
|
||||
return "pass-token";
|
||||
case MSTP_MASTER_STATE_NO_TOKEN:
|
||||
return "no-token";
|
||||
case MSTP_MASTER_STATE_POLL_FOR_MASTER:
|
||||
return "poll-for-master";
|
||||
case MSTP_MASTER_STATE_ANSWER_DATA_REQUEST:
|
||||
return "answer-data-request";
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return "unknown";
|
||||
}
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
#include "hardware.h"
|
||||
#include "init.h"
|
||||
#include "stack.h"
|
||||
@@ -173,10 +174,12 @@ void test_init(
|
||||
void test_task(
|
||||
void)
|
||||
{
|
||||
uint8_t buffer[32] = "BACnet: 0000000\r\n";
|
||||
char buffer[32] = "BACnet: 0000000\r\n";
|
||||
uint8_t nbytes = 17;
|
||||
uint8_t *pBuffer = NULL;
|
||||
uint8_t data_register = 0;
|
||||
|
||||
pBuffer = &buffer[0];
|
||||
if (timer_elapsed_seconds(TIMER_TEST, 1)) {
|
||||
timer_reset(TIMER_TEST);
|
||||
buffer[8] = (MSTP_MAC_Address & BIT0) ? '1' : '0';
|
||||
@@ -186,9 +189,11 @@ 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(buffer, nbytes);
|
||||
serial_bytes_send(pBuffer, nbytes);
|
||||
}
|
||||
if (serial_byte_get(&data_register)) {
|
||||
/* echo the character */
|
||||
serial_byte_send(data_register);
|
||||
if (data_register == '0') {
|
||||
Binary_Output_Level_Set(0, 1, BINARY_INACTIVE);
|
||||
Binary_Output_Level_Sync(0);
|
||||
@@ -207,7 +212,26 @@ void test_task(
|
||||
Binary_Output_Level_Set(1, 1, BINARY_NULL);
|
||||
Binary_Output_Level_Sync(1);
|
||||
}
|
||||
serial_byte_send(data_register);
|
||||
if (data_register == 'm') {
|
||||
sprintf(buffer, "->Master State: ");
|
||||
pBuffer = &buffer[0];
|
||||
nbytes = strlen(pBuffer);
|
||||
serial_bytes_send(pBuffer, nbytes);
|
||||
extern char *dlmstp_master_state_text(void);
|
||||
pBuffer = dlmstp_master_state_text();
|
||||
nbytes = strlen(pBuffer);
|
||||
serial_bytes_send(pBuffer, nbytes);
|
||||
}
|
||||
if (data_register == 'r') {
|
||||
sprintf(buffer, "->Receive State: ");
|
||||
pBuffer = &buffer[0];
|
||||
nbytes = strlen(pBuffer);
|
||||
serial_bytes_send(pBuffer, nbytes);
|
||||
extern char *dlmstp_receive_state_text(void);
|
||||
pBuffer = dlmstp_receive_state_text();
|
||||
nbytes = strlen(pBuffer);
|
||||
serial_bytes_send(pBuffer, nbytes);
|
||||
}
|
||||
serial_byte_send('\r');
|
||||
serial_byte_send('\n');
|
||||
serial_byte_transmit_complete();
|
||||
|
||||
Reference in New Issue
Block a user