Finally got MS/TP communicating on ports/rtos32. I still need to verify that it is doing things correctly since it seems a little slow to respond to service requests. Still more work to do refactoring the state machine.
This commit is contained in:
@@ -111,8 +111,9 @@ int dlmstp_send_pdu(BACNET_ADDRESS * dest, /* destination address */
|
||||
void dlmstp_task(void)
|
||||
{
|
||||
RS485_Check_UART_Data(&MSTP_Port);
|
||||
MSTP_Receive_Frame_FSM(&MSTP_Port);
|
||||
MSTP_Master_Node_FSM(&MSTP_Port);
|
||||
MSTP_Receive_Frame_FSM(&MSTP_Port);
|
||||
if (MSTP_Port.receive_state == MSTP_RECEIVE_STATE_IDLE)
|
||||
MSTP_Master_Node_FSM(&MSTP_Port);
|
||||
}
|
||||
|
||||
/* called about once a millisecond */
|
||||
@@ -175,17 +176,17 @@ uint16_t dlmstp_put_receive(
|
||||
uint8_t * pdu, /* PDU data */
|
||||
uint16_t pdu_len)
|
||||
{
|
||||
if (Receive_Buffer.ready)
|
||||
{
|
||||
if (Receive_Buffer.ready) {
|
||||
/* FIXME: what to do when we miss a message? */
|
||||
pdu_len = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
pdu_len = 0;
|
||||
} else if (pdu_len < sizeof(Receive_Buffer.pdu)) {
|
||||
dlmstp_fill_bacnet_address(&Receive_Buffer.address, src);
|
||||
Receive_Buffer.pdu_len = pdu_len;
|
||||
memmove(Receive_Buffer.pdu, pdu, sizeof(Receive_Buffer.pdu));
|
||||
memmove(Receive_Buffer.pdu, pdu, pdu_len);
|
||||
Receive_Buffer.ready = true;
|
||||
} else {
|
||||
/* FIXME: message too large? */
|
||||
pdu_len = 0;
|
||||
}
|
||||
|
||||
return pdu_len;
|
||||
|
||||
@@ -161,10 +161,8 @@ int main(int argc, char *argv[])
|
||||
#ifdef BACDL_MSTP
|
||||
dlmstp_task();
|
||||
#endif
|
||||
#if (defined(BACDL_ETHERNET) || defined(BACDL_BIP))
|
||||
/* returns 0 bytes on timeout */
|
||||
pdu_len = datalink_receive(&src, &Rx_Buf[0], MAX_MPDU, timeout);
|
||||
#endif
|
||||
/* process */
|
||||
if (pdu_len) {
|
||||
npdu_handler(&src, &Rx_Buf[0], pdu_len);
|
||||
|
||||
@@ -37,7 +37,8 @@ COMPort COM1 115200 // use COM1 with 115200 baud
|
||||
VideoRAM = None // program output sent to debugger - clrscr() crashes it.
|
||||
#elifdef DEBUGCOM3
|
||||
COMPort COM3 115200 9 // use COM3 IRQ9 115200 baud - Everex EV170 serial card
|
||||
VideoRAM = ColorText // program output sent to debugger - clrscr() crashes it.
|
||||
//VideoRAM = ColorText // program output sent to Graphic Card
|
||||
VideoRAM = None // program output sent to debugger - clrscr() crashes it.
|
||||
#else
|
||||
COMPort COM3 115200 9 // use COM3 IRQ9 115200 baud - Everex EV170 serial card
|
||||
VideoRAM = ColorText // program output sent to Graphic Card
|
||||
|
||||
@@ -22,12 +22,13 @@
|
||||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
*********************************************************************/
|
||||
#define PRINT_ENABLED_RS485 0
|
||||
|
||||
#include <stdint.h>
|
||||
#include <rtkernel.h>
|
||||
#include <rtcom.h>
|
||||
#include <itimer.h>
|
||||
#if PRINT_ENABLED
|
||||
#if PRINT_ENABLED_RS485
|
||||
#include <stdio.h>
|
||||
#endif
|
||||
#include "mstp.h"
|
||||
@@ -41,7 +42,7 @@
|
||||
/* COM port number - COM1 = 0 */
|
||||
static int RS485_Port = COM2;
|
||||
/* baud rate */
|
||||
static long RS485_Baud = 38400;
|
||||
static long RS485_Baud = 9600;
|
||||
/* io base address */
|
||||
static long RS485_Base = 0;
|
||||
/* hardware IRQ number */
|
||||
@@ -111,7 +112,7 @@ static RS485_Open_Port(int port, /* COM port number - COM1 = 0 */
|
||||
/* enable the 485 via the DTR pin */
|
||||
RS485_IO_ENABLE(port);
|
||||
RS485_RECEIVE_ENABLE(port);
|
||||
#if PRINT_ENABLED
|
||||
#if PRINT_ENABLED_RS485
|
||||
fprintf(stderr,"RS485: COM%d Enabled\r\n",port+1);
|
||||
#endif
|
||||
|
||||
@@ -139,7 +140,7 @@ void RS485_Send_Frame(volatile struct mstp_port_struct_t *mstp_port, /* port
|
||||
while (!(LineStatus(RS485_Port) & TX_SHIFT_EMPTY))
|
||||
RTKScheduler();
|
||||
RS485_RECEIVE_ENABLE(RS485_Port);
|
||||
#if PRINT_ENABLED
|
||||
#if PRINT_ENABLED_RS485
|
||||
{
|
||||
int i = 0;
|
||||
fprintf(stderr,"RS485 Tx:");
|
||||
|
||||
@@ -30,7 +30,8 @@
|
||||
Locate DiskBuffer DiskIO LowMem 16k 16k // needed by disk boot code
|
||||
NoFPU=0 // Check FPU
|
||||
CPL = 3 // normal priveleges
|
||||
VideoRAM ColorText // program output sent to Graphic Card
|
||||
// VideoRAM ColorText // program output sent to Graphic Card
|
||||
VideoRAM None // program output sent to file and host
|
||||
#endif
|
||||
|
||||
FillRAM HeapMem // remap unused RAM
|
||||
|
||||
Reference in New Issue
Block a user