changed c++ comments to c comments using comment.sh script.

This commit is contained in:
skarg
2006-02-19 01:33:30 +00:00
parent dee63d45bc
commit b686fa7ca7
34 changed files with 975 additions and 1030 deletions
+41 -41
View File
@@ -32,12 +32,12 @@
-------------------------------------------
####COPYRIGHTEND####*/
#include <stdint.h> // for standard integer types uint8_t etc.
#include <stdbool.h> // for the standard bool type.
#include <stdint.h> /* for standard integer types uint8_t etc. */
#include <stdbool.h> /* for the standard bool type. */
#include "bip.h"
#if (defined(BACDL_ETHERNET) || defined(BACDL_BIP))
static int interface = SOCKET_ERROR; // SOCKET_ERROR means no open interface
static int interface = SOCKET_ERROR; /* SOCKET_ERROR means no open interface */
#endif
void bip_set_interface(char *ifname)
@@ -73,50 +73,50 @@ void InterfaceCleanup(void)
#endif
static void NetInitialize(void)
// initialize the TCP/IP stack
/* initialize the TCP/IP stack */
{
int Result;
#ifndef HOST
RTKernelInit(0); // get the kernel going
RTKernelInit(0); /* get the kernel going */
if (!RTKDebugVersion()) // switch of all diagnostics and error messages of RTIP-32
if (!RTKDebugVersion()) /* switch of all diagnostics and error messages of RTIP-32 */
xn_callbacks()->cb_wr_screen_string_fnc = NULL;
CLKSetTimerIntVal(10 * 1000); // 10 millisecond tick
CLKSetTimerIntVal(10 * 1000); /* 10 millisecond tick */
RTKDelay(1);
RTCMOSSetSystemTime(); // get the right time-of-day
RTCMOSSetSystemTime(); /* get the right time-of-day */
#ifdef RTUSB_VER
RTURegisterCallback(USBAX172); // ax172 and ax772 drivers
RTURegisterCallback(USBAX172); /* ax172 and ax772 drivers */
RTURegisterCallback(USBAX772);
RTURegisterCallback(USBKeyboard); // support USB keyboards
FindUSBControllers(); // install USB host controllers
Sleep(2000); // give the USB stack time to enumerate devices
RTURegisterCallback(USBKeyboard); /* support USB keyboards */
FindUSBControllers(); /* install USB host controllers */
Sleep(2000); /* give the USB stack time to enumerate devices */
#endif
#ifdef DHCP
XN_REGISTER_DHCP_CLI() // and optionally the DHCP client
XN_REGISTER_DHCP_CLI() /* and optionally the DHCP client */
#endif
Result = xn_rtip_init(); // Initialize the RTIP stack
Result = xn_rtip_init(); /* Initialize the RTIP stack */
if (Result != 0)
Error("xn_rtip_init failed");
atexit(InterfaceCleanup); // make sure the driver is shut down properly
RTCallDebugger(RT_DBG_CALLRESET, (DWORD) exit, 0); // even if we get restarted by the debugger
atexit(InterfaceCleanup); /* make sure the driver is shut down properly */
RTCallDebugger(RT_DBG_CALLRESET, (DWORD) exit, 0); /* even if we get restarted by the debugger */
Result = BIND_DRIVER(MINOR_0); // tell RTIP what Ethernet driver we want (see netcfg.h)
Result = BIND_DRIVER(MINOR_0); /* tell RTIP what Ethernet driver we want (see netcfg.h) */
if (Result != 0)
Error("driver initialization failed");
#if DEVICE_ID == PRISM_PCMCIA_DEVICE
// if this is a PCMCIA device, start the PCMCIA driver
/* if this is a PCMCIA device, start the PCMCIA driver */
if (RTPCInit(-1, 0, 2, NULL) == 0)
Error("No PCMCIA controller found");
#endif
// Open the interface
/* Open the interface */
interface =
xn_interface_open_config(DEVICE_ID, MINOR_0, ED_IO_ADD, ED_IRQ,
ED_MEM_ADD);
@@ -143,29 +143,29 @@ static void NetInitialize(void)
}
#if DEVICE_ID == PRISM_PCMCIA_DEVICE || DEVICE_ID == PRISM_DEVICE
xn_wlan_setup(interface, // iface_no: value returned by xn_interface_open_config()
"network name", // SSID : network name set in the access point
"station name", // Name : name of this node
0, // Channel : 0 for access points, 1..14 for ad-hoc
0, // KeyIndex: 0 .. 3
"12345", // WEP Key : key to use (5 or 13 bytes)
0); // Flags : see manual and Wlanapi.h for details
Sleep(1000); // wireless devices need a little time before they can be used
#endif // WLAN device
xn_wlan_setup(interface, /* iface_no: value returned by xn_interface_open_config() */
"network name", /* SSID : network name set in the access point */
"station name", /* Name : name of this node */
0, /* Channel : 0 for access points, 1..14 for ad-hoc */
0, /* KeyIndex: 0 .. 3 */
"12345", /* WEP Key : key to use (5 or 13 bytes) */
0); /* Flags : see manual and Wlanapi.h for details */
Sleep(1000); /* wireless devices need a little time before they can be used */
#endif /* WLAN device */
#if defined(AUTO_IP) // use xn_autoip() to get an IP address
#if defined(AUTO_IP) /* use xn_autoip() to get an IP address */
Result = xn_autoip(interface, MinIP, MaxIP, NetMask, TargetIP);
if (Result == SOCKET_ERROR)
Error("xn_autoip failed");
else {
printf("Auto-assigned IP address %i.%i.%i.%i\n", TargetIP[0],
TargetIP[1], TargetIP[2], TargetIP[3]);
// define default gateway and DNS server
/* define default gateway and DNS server */
xn_rt_add(RT_DEFAULT, ip_ffaddr, DefaultGateway, 1, interface,
RT_INF);
xn_set_server_list((DWORD *) DNSServer, 1);
}
#elif defined(DHCP) // use DHCP
#elif defined(DHCP) /* use DHCP */
{
DHCP_param param[] = { {SUBNET_MASK, 1}
, {DNS_OP, 1}
@@ -174,11 +174,11 @@ static void NetInitialize(void)
DHCP_session DS;
DHCP_conf DC;
xn_init_dhcp_conf(&DC); // load default DHCP options
DC.plist = param; // add MASK, DNS, and gateway options
xn_init_dhcp_conf(&DC); /* load default DHCP options */
DC.plist = param; /* add MASK, DNS, and gateway options */
DC.plist_entries = sizeof(param) / sizeof(param[0]);
printf("Contacting DHCP server, please wait...\n");
Result = xn_dhcp(interface, &DS, &DC); // contact DHCP server
Result = xn_dhcp(interface, &DS, &DC); /* contact DHCP server */
if (Result == SOCKET_ERROR)
Error("xn_dhcp failed");
memcpy(TargetIP, DS.client_ip, 4);
@@ -186,16 +186,16 @@ static void NetInitialize(void)
TargetIP[2], TargetIP[3]);
}
#else
// Set the IP address and interface
/* Set the IP address and interface */
printf("Using static IP address %i.%i.%i.%i\n", TargetIP[0],
TargetIP[1], TargetIP[2], TargetIP[3]);
Result = xn_set_ip(interface, TargetIP, NetMask);
// define default gateway and DNS server
/* define default gateway and DNS server */
xn_rt_add(RT_DEFAULT, ip_ffaddr, DefaultGateway, 1, interface, RT_INF);
xn_set_server_list((DWORD *) DNSServer, 1);
#endif
#else // HOST defined, run on Windows
#else /* HOST defined, run on Windows */
WSADATA wd;
Result = WSAStartup(0x0101, &wd);
@@ -209,7 +209,7 @@ static void NetInitialize(void)
bool bip_init(void)
{
int rv = 0; // return from socket lib calls
int rv = 0; /* return from socket lib calls */
struct sockaddr_in sin = { -1 };
int value = 1;
int sock_fd = -1;
@@ -218,7 +218,7 @@ bool bip_init(void)
bip_set_address(TargetIP[0], TargetIP[1], TargetIP[2], TargetIP[3]);
// FIXME:
/* FIXME: */
#if 0
bip_set_address(NetMask[0], NetMask[1], NetMask[2], NetMask[3]);
extern unsigned long bip_get_addr(void);
@@ -232,13 +232,13 @@ bool bip_init(void)
bip_set_port(0xBAC0);
#endif
// assumes that the driver has already been initialized
/* assumes that the driver has already been initialized */
sock_fd = socket(AF_INET, SOCK_DGRAM, IPROTO_UDP);
bip_set_socket(sock_fd);
if (sock_fd < 0)
return false;
// bind the socket to the local port number and IP address
/* bind the socket to the local port number and IP address */
sin.sin_family = AF_INET;
sin.sin_addr.s_addr = htonl(INADDR_ANY);
sin.sin_port = htons(bip_get_port());
+54 -54
View File
@@ -23,10 +23,10 @@
*
*********************************************************************/
#include <stdint.h> // for standard integer types uint8_t etc.
#include <stdbool.h> // for the standard bool type.
#include <stdio.h> // for the standard bool type.
#include <stdlib.h> // for the standard bool type.
#include <stdint.h> /* for standard integer types uint8_t etc. */
#include <stdbool.h> /* for the standard bool type. */
#include <stdio.h> /* for the standard bool type. */
#include <stdlib.h> /* for the standard bool type. */
#include <rttarget.h>
#include <rtk32.h>
#include <clock.h>
@@ -35,17 +35,17 @@
#include "ethernet.h"
#include "bacdcode.h"
// commonly used comparison address for ethernet
/* commonly used comparison address for ethernet */
uint8_t Ethernet_Broadcast[MAX_MAC_LEN] =
{ 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF };
// commonly used empty address for ethernet quick compare
/* commonly used empty address for ethernet quick compare */
uint8_t Ethernet_Empty_MAC[MAX_MAC_LEN] = { 0, 0, 0, 0, 0, 0 };
// my local device data - MAC address
/* my local device data - MAC address */
uint8_t Ethernet_MAC_Address[MAX_MAC_LEN] = { 0, 0, 0, 0, 0, 0 };
static SOCKET Ethernet_Socket = -1;
// used for binding 802.2
/* used for binding 802.2 */
static struct sockaddr Ethernet_Address = { 0 };
bool ethernet_valid(void)
@@ -67,9 +67,9 @@ bool ethernet_init(char *interface_name)
int value = 1;
(void) interface_name;
// setup the socket
/* setup the socket */
Ethernet_Socket = socket(AF_INET, SOCK_RAW, 0);
//Ethernet_Socket = socket(AF_INET, SOCK_STREAM, 0);
/*Ethernet_Socket = socket(AF_INET, SOCK_STREAM, 0); */
if (Ethernet_Socket < 0)
fprintf(stderr, "ethernet: failed to bind to socket!\r\n");
Ethernet_Address.sa_family = AF_INET;
@@ -77,24 +77,24 @@ bool ethernet_init(char *interface_name)
if (bind(Ethernet_Socket,
&Ethernet_Address, sizeof(Ethernet_Address)) == SOCKET_ERROR)
fprintf(stderr, "ethernet: failed to bind to socket!\r\n");
//setsockopt(Ethernet_Socket,SOL_SOCKET,SO_802_2,(char *)&value,sizeof(value));
/*setsockopt(Ethernet_Socket,SOL_SOCKET,SO_802_2,(char *)&value,sizeof(value)); */
return ethernet_valid();
}
/* function to send a packet out the 802.2 socket */
/* returns bytes sent on success, negative number on failure */
int ethernet_send(BACNET_ADDRESS * dest, // destination address
BACNET_ADDRESS * src, // source address
uint8_t * pdu, // any data to be sent - may be null
unsigned pdu_len) // number of bytes of data
{
int ethernet_send(BACNET_ADDRESS * dest, /* destination address */
BACNET_ADDRESS * src, /* source address */
uint8_t * pdu, /* any data to be sent - may be null */
unsigned pdu_len)
{ /* number of bytes of data */
int bytes = 0;
uint8_t mtu[MAX_MPDU] = { 0 };
int mtu_len = 0;
int i = 0;
// don't waste time if the socket is not valid
/* don't waste time if the socket is not valid */
if (Ethernet_Socket < 0) {
fprintf(stderr, "ethernet: 802.2 socket is invalid!\n");
return -1;
@@ -127,7 +127,7 @@ int ethernet_send(BACNET_ADDRESS * dest, // destination address
/* packet length */
mtu_len += encode_unsigned16(&mtu[12],
3 /*DSAP,SSAP,LLC */ + pdu_len);
// Logical PDU portion
/* Logical PDU portion */
mtu[mtu_len++] = 0x82; /* DSAP for BACnet */
mtu[mtu_len++] = 0x82; /* SSAP for BACnet */
mtu[mtu_len++] = 0x03; /* Control byte in header */
@@ -146,12 +146,12 @@ int ethernet_send(BACNET_ADDRESS * dest, // destination address
/* function to send a packet out the 802.2 socket */
/* returns bytes sent on success, negative number on failure */
int ethernet_send_pdu(BACNET_ADDRESS * dest, // destination address
uint8_t * pdu, // any data to be sent - may be null
unsigned pdu_len) // number of bytes of data
{
int i = 0; // counter
BACNET_ADDRESS src = { 0 }; // source address
int ethernet_send_pdu(BACNET_ADDRESS * dest, /* destination address */
uint8_t * pdu, /* any data to be sent - may be null */
unsigned pdu_len)
{ /* number of bytes of data */
int i = 0; /* counter */
BACNET_ADDRESS src = { 0 }; /* source address */
for (i = 0; i < 6; i++) {
src.mac[i] = Ethernet_MAC_Address[i];
@@ -159,22 +159,22 @@ int ethernet_send_pdu(BACNET_ADDRESS * dest, // destination address
}
/* function to send a packet out the 802.2 socket */
/* returns 1 on success, 0 on failure */
return ethernet_send(dest, // destination address
&src, // source address
pdu, // any data to be sent - may be null
pdu_len); // number of bytes of data
return ethernet_send(dest, /* destination address */
&src, /* source address */
pdu, /* any data to be sent - may be null */
pdu_len); /* number of bytes of data */
}
// receives an 802.2 framed packet
// returns the number of octets in the PDU, or zero on failure
uint16_t ethernet_receive(BACNET_ADDRESS * src, // source address
uint8_t * pdu, // PDU data
uint16_t max_pdu, // amount of space available in the PDU
unsigned timeout) // number of milliseconds to wait for a packet
{
/* receives an 802.2 framed packet */
/* returns the number of octets in the PDU, or zero on failure */
uint16_t ethernet_receive(BACNET_ADDRESS * src, /* source address */
uint8_t * pdu, /* PDU data */
uint16_t max_pdu, /* amount of space available in the PDU */
unsigned timeout)
{ /* number of milliseconds to wait for a packet */
int received_bytes;
uint8_t buf[MAX_MPDU] = { 0 }; // data
uint16_t pdu_len = 0; // return value
uint8_t buf[MAX_MPDU] = { 0 }; /* data */
uint16_t pdu_len = 0; /* return value */
fd_set read_fds;
int max;
struct timeval select_timeout;
@@ -206,9 +206,9 @@ uint16_t ethernet_receive(BACNET_ADDRESS * src, // source address
/* See if there is a problem */
if (received_bytes < 0) {
// EAGAIN Non-blocking I/O has been selected
// using O_NONBLOCK and no data
// was immediately available for reading.
/* EAGAIN Non-blocking I/O has been selected */
/* using O_NONBLOCK and no data */
/* was immediately available for reading. */
if (errno != EAGAIN)
fprintf(stderr,
"ethernet: Read error in receiving packet: %s\n",
@@ -221,28 +221,28 @@ uint16_t ethernet_receive(BACNET_ADDRESS * src, // source address
/* the signature of an 802.2 BACnet packet */
if ((buf[14] != 0x82) && (buf[15] != 0x82)) {
//fprintf(stderr,"ethernet: Non-BACnet packet\n");
/*fprintf(stderr,"ethernet: Non-BACnet packet\n"); */
return 0;
}
// copy the source address
/* copy the source address */
src->mac_len = 6;
memmove(src->mac, &buf[6], 6);
// check destination address for when
// the Ethernet card is in promiscious mode
/* check destination address for when */
/* the Ethernet card is in promiscious mode */
if ((memcmp(&buf[0], Ethernet_MAC_Address, 6) != 0)
&& (memcmp(&buf[0], Ethernet_Broadcast, 6) != 0)) {
//fprintf(stderr, "ethernet: This packet isn't for us\n");
/*fprintf(stderr, "ethernet: This packet isn't for us\n"); */
return 0;
}
(void) decode_unsigned16(&buf[12], &pdu_len);
pdu_len -= 3 /* DSAP, SSAP, LLC Control */ ;
// copy the buffer into the PDU
/* copy the buffer into the PDU */
if (pdu_len < max_pdu)
memmove(&pdu[0], &buf[17], pdu_len);
// ignore packets that are too large
// client should check my max apdu first
/* ignore packets that are too large */
/* client should check my max apdu first */
else
pdu_len = 0;
@@ -258,7 +258,7 @@ void ethernet_get_my_address(BACNET_ADDRESS * my_address)
my_address->mac[i] = Ethernet_MAC_Address[i];
my_address->mac_len++;
}
my_address->net = 0; // local only, no routing
my_address->net = 0; /* local only, no routing */
my_address->len = 0;
for (i = 0; i < MAX_MAC_LEN; i++) {
my_address->adr[i] = 0;
@@ -278,9 +278,9 @@ void ethernet_set_my_address(BACNET_ADDRESS * my_address)
return;
}
void ethernet_get_broadcast_address(BACNET_ADDRESS * dest) // destination address
{
int i = 0; // counter
void ethernet_get_broadcast_address(BACNET_ADDRESS * dest)
{ /* destination address */
int i = 0; /* counter */
if (dest) {
for (i = 0; i < 6; i++) {
@@ -288,7 +288,7 @@ void ethernet_get_broadcast_address(BACNET_ADDRESS * dest) // destination a
}
dest->mac_len = 6;
dest->net = BACNET_BROADCAST_NETWORK;
dest->len = 0; // denotes broadcast address
dest->len = 0; /* denotes broadcast address */
for (i = 0; i < MAX_MAC_LEN; i++) {
dest->adr[i] = 0;
}
@@ -299,7 +299,7 @@ void ethernet_get_broadcast_address(BACNET_ADDRESS * dest) // destination a
void ethernet_debug_address(const char *info, BACNET_ADDRESS * dest)
{
int i = 0; // counter
int i = 0; /* counter */
if (info)
fprintf(stderr, "%s", info);
+19 -19
View File
@@ -36,15 +36,15 @@ extern void RTEmuInit(void);
#endif
/* DISK SYSTEM */
#ifdef DOC // include DiskOnChip driver
#ifdef DOC /* include DiskOnChip driver */
#include <rtfiles.h>
#define RTF_MAX_FILES 16 // support for more open files (default is 8)
#define RTF_BUFFERS_IN_BSS // we do not need file I/O before the run-time
#include <rtfdata.c> // system is initialized
#define RTF_MAX_FILES 16 /* support for more open files (default is 8) */
#define RTF_BUFFERS_IN_BSS /* we do not need file I/O before the run-time */
#include <rtfdata.c> /* system is initialized */
//#define READ_HEAD_BUFFER_SIZE 2048+4
/*#define READ_HEAD_BUFFER_SIZE 2048+4 */
//static BYTE ReadAheadBuffer[READ_HEAD_BUFFER_SIZE];
/*static BYTE ReadAheadBuffer[READ_HEAD_BUFFER_SIZE]; */
static RTFDrvFLPYData FLPYDriveAData = { 0 };
static RTFDrvDOCData DOCDriveData = { 0 };
@@ -108,17 +108,17 @@ RTFileSystem *RTFileSystemList[] = {
/*-----------------------------------*/
VOIDEXPORT Init(void)
{
(void) RTSetFlags(RT_MM_VIRTUAL, 1); // this is the better method
(void) RTCMOSExtendHeap(); // get as much memory as we can
RTCMOSSetSystemTime(); // get the right date and time
RTEmuInit(); // set up floating point emulation
// pizza - RTHaltCPL3 appears to cause problems with file handling
//RTIdleHandler = (void RTTAPI *)RTHaltCPL3; // low power when idle
// not needed with pre-emptive
//RTKTimeSlice(2); // allow same priority task switch
RTKConfig.Flags |= RF_PREEMPTIVE; // preemptive multitasking
RTKConfig.Flags |= RF_WIN32MUTEX_MUTEX; // Win32 mutexes are RTK32 mutexes
RTKConfig.Flags |= RF_FPCONTEXT; // saves floating point context for tasks
RTKConfig.HookedIRQs |= 1 << 1; // hook the keyboard IRQ
RTKConfig.DefaultTaskStackSize = 1024 * 8; // for Win32 task stacks req = 0
(void) RTSetFlags(RT_MM_VIRTUAL, 1); /* this is the better method */
(void) RTCMOSExtendHeap(); /* get as much memory as we can */
RTCMOSSetSystemTime(); /* get the right date and time */
RTEmuInit(); /* set up floating point emulation */
/* pizza - RTHaltCPL3 appears to cause problems with file handling */
/*RTIdleHandler = (void RTTAPI *)RTHaltCPL3; // low power when idle */
/* not needed with pre-emptive */
/*RTKTimeSlice(2); // allow same priority task switch */
RTKConfig.Flags |= RF_PREEMPTIVE; /* preemptive multitasking */
RTKConfig.Flags |= RF_WIN32MUTEX_MUTEX; /* Win32 mutexes are RTK32 mutexes */
RTKConfig.Flags |= RF_FPCONTEXT; /* saves floating point context for tasks */
RTKConfig.HookedIRQs |= 1 << 1; /* hook the keyboard IRQ */
RTKConfig.DefaultTaskStackSize = 1024 * 8; /* for Win32 task stacks req = 0 */
}
+19 -19
View File
@@ -23,8 +23,8 @@
*
*********************************************************************/
// This is one way to use the embedded BACnet stack under RTOS-32
// compiled with Borland C++ 5.02
/* This is one way to use the embedded BACnet stack under RTOS-32 */
/* compiled with Borland C++ 5.02 */
#include <stddef.h>
#include <stdint.h>
#include <stdio.h>
@@ -36,23 +36,23 @@
#include "handlers.h"
#include "net.h"
// buffers used for transmit and receive
/* buffers used for transmit and receive */
static uint8_t Rx_Buf[MAX_MPDU] = { 0 };
#ifdef BACDL_MSTP
volatile struct mstp_port_struct_t MSTP_Port; // port data
static uint8_t MSTP_MAC_Address = 0x05; // local MAC address
volatile struct mstp_port_struct_t MSTP_Port; /* port data */
static uint8_t MSTP_MAC_Address = 0x05; /* local MAC address */
#endif
static void Init_Service_Handlers(void)
{
// we need to handle who-is to support dynamic device binding
/* we need to handle who-is to support dynamic device binding */
apdu_set_unconfirmed_handler(SERVICE_UNCONFIRMED_WHO_IS, WhoIsHandler);
// set the handler for all the services we don't implement
// It is required to send the proper reject message...
/* set the handler for all the services we don't implement */
/* It is required to send the proper reject message... */
apdu_set_unrecognized_service_handler_handler
(UnrecognizedServiceHandler);
// we must implement read property - it's required!
/* we must implement read property - it's required! */
apdu_set_confirmed_handler(SERVICE_CONFIRMED_READ_PROPERTY,
ReadPropertyHandler);
apdu_set_confirmed_handler(SERVICE_CONFIRMED_WRITE_PROPERTY,
@@ -61,15 +61,15 @@ static void Init_Service_Handlers(void)
int main(int argc, char *argv[])
{
BACNET_ADDRESS src = { 0 }; // address where message came from
BACNET_ADDRESS src = { 0 }; /* address where message came from */
uint16_t pdu_len = 0;
unsigned timeout = 100; // milliseconds
unsigned timeout = 100; /* milliseconds */
(void) argc;
(void) argv;
Device_Set_Object_Instance_Number(126);
Init_Service_Handlers();
// init the physical layer
/* init the physical layer */
#ifdef BACDL_BIP
if (!bip_init())
return 1;
@@ -84,22 +84,22 @@ int main(int argc, char *argv[])
#endif
// loop forever
/* loop forever */
for (;;) {
// input
/* input */
#ifdef BACDL_MSTP
MSTP_Millisecond_Timer(&MSTP_Port);
// note: also called by RS-485 Receive ISR
/* note: also called by RS-485 Receive ISR */
RS485_Check_UART_Data(&MSTP_Port);
MSTP_Receive_Frame_FSM(&MSTP_Port);
#endif
#if (defined(BACDL_ETHERNET) || defined(BACDL_BIP))
// returns 0 bytes on timeout
/* returns 0 bytes on timeout */
pdu_len = bacdl_receive(&src, &Rx_Buf[0], MAX_MPDU, timeout);
#endif
// process
/* process */
if (pdu_len) {
npdu_handler(&src, &Rx_Buf[0], pdu_len);
@@ -108,11 +108,11 @@ int main(int argc, char *argv[])
I_Am_Request = false;
Send_IAm();
}
// output
/* output */
#ifdef BACDL_MSTP
MSTP_Master_Node_FSM(&MSTP_Port);
#endif
// blink LEDs, Turn on or off outputs, etc
/* blink LEDs, Turn on or off outputs, etc */
}
}
+23 -23
View File
@@ -28,41 +28,41 @@
*/
// #define AUTO_IP // use xn_autoip() to get an IP address
// #define DHCP // if you enable this, you must also link library dhcpc.lib
/* #define AUTO_IP // use xn_autoip() to get an IP address */
/* #define DHCP // if you enable this, you must also link library dhcpc.lib */
#if defined(AUTO_IP) // use xn_autoip() to get an IP address
static BYTE TargetIP[] = { 0, 0, 0, 0 }; // will be filled at run-time
#if defined(AUTO_IP) /* use xn_autoip() to get an IP address */
static BYTE TargetIP[] = { 0, 0, 0, 0 }; /* will be filled at run-time */
static BYTE NetMask[] = { 255, 255, 255, 0 };
static BYTE MinIP[] = { 192, 168, 1, 128 };
static BYTE MaxIP[] = { 192, 168, 1, 255 };
static BYTE DefaultGateway[] = { 192, 168, 1, 1 }; // set to zero if not available or required
static BYTE DNSServer[] = { 192, 168, 1, 1 }; // ditto
#elif defined(DHCP) // use DHCP
static BYTE DefaultGateway[] = { 192, 168, 1, 1 }; /* set to zero if not available or required */
static BYTE DNSServer[] = { 192, 168, 1, 1 }; /* ditto */
#elif defined(DHCP) /* use DHCP */
#include <dhcpcapi.h>
static BYTE TargetIP[] = { 0, 0, 0, 0 }; // will be filled at run-time
#else // static IP address assignment (default)
static BYTE TargetIP[] = { 0, 0, 0, 0 }; /* will be filled at run-time */
#else /* static IP address assignment (default) */
static BYTE TargetIP[] = { 192, 168, 0, 50 };
static BYTE NetMask[] = { 255, 255, 255, 0 };
static BYTE DefaultGateway[] = { 192, 168, 0, 1 }; // set to zero if not available or required
static BYTE DNSServer[] = { 192, 168, 0, 1 }; // ditto
static BYTE DefaultGateway[] = { 192, 168, 0, 1 }; /* set to zero if not available or required */
static BYTE DNSServer[] = { 192, 168, 0, 1 }; /* ditto */
#endif
#define DEVICE_ID DAVICOM_DEVICE // define your device type here
#define DEVICE_ID DAVICOM_DEVICE /* define your device type here */
#ifndef DEVICE_ID
#error You must define Ethernet driver/resources and IP address/net mask here
#endif
// The following values are ignored for PCI devices (the BIOS supplies
// them), but they must be set correctly for ISA/PCMCIA systems and for
// PCI devices if you do not have a BIOS
/* The following values are ignored for PCI devices (the BIOS supplies */
/* them), but they must be set correctly for ISA/PCMCIA systems and for */
/* PCI devices if you do not have a BIOS */
#define ED_IO_ADD 0x300 // I/O address of the device
#define ED_IRQ 5 // IRQ of the device
#define ED_MEM_ADD 0 // Memory Window (only some devices)
#define ED_IO_ADD 0x300 /* I/O address of the device */
#define ED_IRQ 5 /* IRQ of the device */
#define ED_MEM_ADD 0 /* Memory Window (only some devices) */
// Define function to pull in the required driver
/* Define function to pull in the required driver */
#if DEVICE_ID == NE2000_DEVICE
#define BIND_DRIVER xn_bind_ne2000
@@ -87,17 +87,17 @@ static BYTE DNSServer[] = { 192, 168, 0, 1 }; // ditto
#elif DEVICE_ID == RHINE_DEVICE
#define BIND_DRIVER xn_bind_rhine
#elif DEVICE_ID == AX172_DEVICE
#include <rtusb.h> // must also link Rtusb.lib and UsbInit.cpp
#include <rtusb.h> /* must also link Rtusb.lib and UsbInit.cpp */
#define BIND_DRIVER xn_bind_ax172
#elif DEVICE_ID == AX772_DEVICE
#include <rtusb.h> // must also link Rtusb.lib and UsbInit.cpp
#include <rtusb.h> /* must also link Rtusb.lib and UsbInit.cpp */
#define BIND_DRIVER xn_bind_ax772
#elif DEVICE_ID == PRISM_DEVICE
#include <wlanapi.h> // must also link Wlan.lib
#include <wlanapi.h> /* must also link Wlan.lib */
#define BIND_DRIVER xn_bind_prism
#elif DEVICE_ID == PRISM_PCMCIA_DEVICE
#include <rtpcmcia.h>
#include <wlanapi.h> // must also link Wlan.lib
#include <wlanapi.h> /* must also link Wlan.lib */
#define BIND_DRIVER xn_bind_prism_pcmcia
#else
#error Invalid DEVICE_ID value
+14 -14
View File
@@ -29,7 +29,7 @@
#include <itimer.h>
#include "mstp.h"
// note: use the RTKernel-C API so that it can use this library
/* note: use the RTKernel-C API so that it can use this library */
#define RS485_IO_ENABLE(p) ModemControl(p,0,DTR);
#define RS485_TRANSMIT_ENABLE(p) ModemControl(p,1,RTS);
@@ -101,11 +101,11 @@ void RS485_Initialize(void)
RS485_Open_Port(RS485_Port, RS485_Baud, RS485_Base, RS485_IRQ_Number);
}
void RS485_Send_Frame(volatile struct mstp_port_struct_t *mstp_port, // port specific data
uint8_t * buffer, // frame to send (up to 501 bytes of data)
uint16_t nbytes) // number of bytes of data (up to 501)
{
bool status = true; // return value
void RS485_Send_Frame(volatile struct mstp_port_struct_t *mstp_port, /* port specific data */
uint8_t * buffer, /* frame to send (up to 501 bytes of data) */
uint16_t nbytes)
{ /* number of bytes of data (up to 501) */
bool status = true; /* return value */
(void) mstp_port;
RS485_TRANSMIT_ENABLE(RS485_Port);
@@ -119,23 +119,23 @@ void RS485_Send_Frame(volatile struct mstp_port_struct_t *mstp_port, // port
return;
}
void RS485_Check_UART_Data(volatile struct mstp_port_struct_t *mstp_port) // port specific data
{
void RS485_Check_UART_Data(volatile struct mstp_port_struct_t *mstp_port)
{ /* port specific data */
COMData com_data = 0; /* byte from COM driver */
unsigned timeout = 10; // milliseconds to wait for a character
unsigned timeout = 10; /* milliseconds to wait for a character */
Duration ticks; /* duration to wait for data */
if (mstp_port->ReceiveError) {
// wait for state machine to clear this
/* wait for state machine to clear this */
}
// wait for state machine to read from the DataRegister
/* wait for state machine to read from the DataRegister */
else if (!mstp_port->DataAvailable) {
// check for data
/* check for data */
ticks = MilliSecsToTicks(timeout);
if (!ticks)
ticks = 1;
if (RTKGetTimed(ReceiveBuffer[RS485_Port], &com_data, ticks)) {
// if error,
/* if error, */
if (com_data & (COM_OVERRUN << 8))
mstp_port->ReceiveError = true;
else if (com_data & (COM_FRAME << 8))
@@ -150,5 +150,5 @@ void RS485_Check_UART_Data(volatile struct mstp_port_struct_t *mstp_port)
void RS485_Process_Tx_Message(void)
{
// nothing to do
/* nothing to do */
}
+1 -1
View File
@@ -1,7 +1,7 @@
#ifndef STDBOOL_H
#define STDBOOL_H
// C99 Boolean types for compilers without C99 support
/* C99 Boolean types for compilers without C99 support */
#ifndef __cplusplus
typedef int _Bool;
+12 -12
View File
@@ -1,19 +1,19 @@
// Defines the standard integer types that are used in code
// for the x86 processor and Borland Compiler
/* Defines the standard integer types that are used in code */
/* for the x86 processor and Borland Compiler */
#ifndef STDINT_H
#define STDINT_H
#include <stddef.h>
typedef unsigned char uint8_t; // 1 byte 0 to 255
typedef signed char int8_t; // 1 byte -127 to 127
typedef unsigned short uint16_t; // 2 bytes 0 to 65535
typedef signed short int16_t; // 2 bytes -32767 to 32767
//typedef unsigned short long uint24_t; // 3 bytes 0 to 16777215
typedef unsigned long uint32_t; // 4 bytes 0 to 4294967295
typedef signed long int32_t; // 4 bytes -2147483647 to 2147483647
// typedef signed long long int64_t;
// typedef unsigned long long uint64_t;
typedef unsigned char uint8_t; /* 1 byte 0 to 255 */
typedef signed char int8_t; /* 1 byte -127 to 127 */
typedef unsigned short uint16_t; /* 2 bytes 0 to 65535 */
typedef signed short int16_t; /* 2 bytes -32767 to 32767 */
/*typedef unsigned short long uint24_t; // 3 bytes 0 to 16777215 */
typedef unsigned long uint32_t; /* 4 bytes 0 to 4294967295 */
typedef signed long int32_t; /* 4 bytes -2147483647 to 2147483647 */
/* typedef signed long long int64_t; */
/* typedef unsigned long long uint64_t; */
#endif // STDINT_H
#endif /* STDINT_H */