corrected BIP for the Win32 and RTOS32 builds. Compiled and tested under Borland C++ 5.02and Visual C++ 6 SP5.
This commit is contained in:
@@ -159,7 +159,7 @@ static int bip_send(
|
||||
else
|
||||
mtu[1] = 0x0A; /* Original-Unicast-NPDU */
|
||||
mtu_len = 2;
|
||||
mtu_len += encode_unsigned16(&mtu[mtu_len], pdu_len);
|
||||
mtu_len += encode_unsigned16(&mtu[mtu_len], pdu_len + 4 /*inclusive*/);
|
||||
memcpy(&mtu[mtu_len], pdu, pdu_len);
|
||||
mtu_len += pdu_len;
|
||||
|
||||
|
||||
Binary file not shown.
@@ -0,0 +1,316 @@
|
||||
# Microsoft Developer Studio Project File - Name="bacnet" - Package Owner=<4>
|
||||
# Microsoft Developer Studio Generated Build File, Format Version 6.00
|
||||
# ** DO NOT EDIT **
|
||||
|
||||
# TARGTYPE "Win32 (x86) Console Application" 0x0103
|
||||
|
||||
CFG=bacnet - Win32 Debug
|
||||
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
|
||||
!MESSAGE use the Export Makefile command and run
|
||||
!MESSAGE
|
||||
!MESSAGE NMAKE /f "bacnet.mak".
|
||||
!MESSAGE
|
||||
!MESSAGE You can specify a configuration when running NMAKE
|
||||
!MESSAGE by defining the macro CFG on the command line. For example:
|
||||
!MESSAGE
|
||||
!MESSAGE NMAKE /f "bacnet.mak" CFG="bacnet - Win32 Debug"
|
||||
!MESSAGE
|
||||
!MESSAGE Possible choices for configuration are:
|
||||
!MESSAGE
|
||||
!MESSAGE "bacnet - Win32 Release" (based on "Win32 (x86) Console Application")
|
||||
!MESSAGE "bacnet - Win32 Debug" (based on "Win32 (x86) Console Application")
|
||||
!MESSAGE
|
||||
|
||||
# Begin Project
|
||||
# PROP AllowPerConfigDependencies 0
|
||||
# PROP Scc_ProjName ""
|
||||
# PROP Scc_LocalPath ""
|
||||
CPP=cl.exe
|
||||
RSC=rc.exe
|
||||
|
||||
!IF "$(CFG)" == "bacnet - Win32 Release"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 0
|
||||
# PROP BASE Output_Dir "Release"
|
||||
# PROP BASE Intermediate_Dir "Release"
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 0
|
||||
# PROP Output_Dir "Release"
|
||||
# PROP Intermediate_Dir "Release"
|
||||
# PROP Ignore_Export_Lib 0
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
|
||||
# ADD CPP /nologo /W3 /GX /O2 /I "c:\code\bacnet-stack\\" /I "c:\code\bacnet-stack\ports\win32\\" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /FD /c
|
||||
# SUBTRACT CPP /YX
|
||||
# ADD BASE RSC /l 0x409 /d "NDEBUG"
|
||||
# ADD RSC /l 0x409 /d "NDEBUG"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
|
||||
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib wsock32.dll /nologo /subsystem:console /machine:I386
|
||||
|
||||
!ELSEIF "$(CFG)" == "bacnet - Win32 Debug"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 1
|
||||
# PROP BASE Output_Dir "Debug"
|
||||
# PROP BASE Intermediate_Dir "Debug"
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 1
|
||||
# PROP Output_Dir "Debug"
|
||||
# PROP Intermediate_Dir "Debug"
|
||||
# PROP Ignore_Export_Lib 0
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
|
||||
# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /I "c:\code\bacnet-stack\\" /I "c:\code\bacnet-stack\ports\win32\\" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /D "BACDL_BIP" /FD /GZ /c
|
||||
# SUBTRACT CPP /YX
|
||||
# ADD BASE RSC /l 0x409 /d "_DEBUG"
|
||||
# ADD RSC /l 0x409 /d "_DEBUG"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
|
||||
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib wsock32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
|
||||
|
||||
!ENDIF
|
||||
|
||||
# Begin Target
|
||||
|
||||
# Name "bacnet - Win32 Release"
|
||||
# Name "bacnet - Win32 Debug"
|
||||
# Begin Group "Source Files"
|
||||
|
||||
# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\abort.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\address.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\ai.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\ao.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\apdu.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\bacdcode.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\bacerror.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\bigend.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\bip.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\crc.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\datalink.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\device.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\handlers.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\iam.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\main.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\npdu.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\reject.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\ringbuf.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\rp.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\tsm.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\whois.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\wp.c
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "Header Files"
|
||||
|
||||
# PROP Default_Filter "h;hpp;hxx;hm;inl"
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\abort.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\address.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\ai.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\ao.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\apdu.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\arcnet.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\bacdcode.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\bacdef.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\bacenum.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\bacerror.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\bigend.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\bip.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\bits.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\bytes.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\config.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\crc.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\datalink.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\device.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\ethernet.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\handlers.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\iam.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\mstp.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\npdu.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\reject.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\ringbuf.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\rp.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\rs485.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\stdbool.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\stdint.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\tsm.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\whois.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\wp.h
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "Resource Files"
|
||||
|
||||
# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
|
||||
# End Group
|
||||
# End Target
|
||||
# End Project
|
||||
@@ -0,0 +1,29 @@
|
||||
Microsoft Developer Studio Workspace File, Format Version 6.00
|
||||
# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
|
||||
|
||||
###############################################################################
|
||||
|
||||
Project: "bacnet"=".\bacnet.dsp" - Package Owner=<4>
|
||||
|
||||
Package=<5>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
Package=<4>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
###############################################################################
|
||||
|
||||
Global:
|
||||
|
||||
Package=<5>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
Package=<3>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
###############################################################################
|
||||
|
||||
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,53 @@
|
||||
<html>
|
||||
<body>
|
||||
<pre>
|
||||
<h1>Build Log</h1>
|
||||
<h3>
|
||||
--------------------Configuration: bacnet - Win32 Debug--------------------
|
||||
</h3>
|
||||
<h3>Command Lines</h3>
|
||||
Creating temporary file "C:\DOCUME~1\stk01\LOCALS~1\Temp\RSPE11.tmp" with contents
|
||||
[
|
||||
/nologo /MLd /W3 /Gm /GX /ZI /Od /I "c:\code\bacnet-stack\\" /I "c:\code\bacnet-stack\ports\win32\\" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /D "BACDL_BIP" /Fo"Debug/" /Fd"Debug/" /FD /GZ /c
|
||||
"C:\code\bacnet-stack\ports\win32\main.c"
|
||||
]
|
||||
Creating command line "cl.exe @C:\DOCUME~1\stk01\LOCALS~1\Temp\RSPE11.tmp"
|
||||
Creating temporary file "C:\DOCUME~1\stk01\LOCALS~1\Temp\RSPE12.tmp" with contents
|
||||
[
|
||||
kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib wsock32.lib /nologo /subsystem:console /incremental:yes /pdb:"Debug/bacnet.pdb" /debug /machine:I386 /out:"Debug/bacnet.exe" /pdbtype:sept
|
||||
".\Debug\bip.obj"
|
||||
".\Debug\main.obj"
|
||||
".\Debug\abort.obj"
|
||||
".\Debug\address.obj"
|
||||
".\Debug\ai.obj"
|
||||
".\Debug\ao.obj"
|
||||
".\Debug\apdu.obj"
|
||||
".\Debug\bacdcode.obj"
|
||||
".\Debug\bacerror.obj"
|
||||
".\Debug\bigend.obj"
|
||||
".\Debug\crc.obj"
|
||||
".\Debug\datalink.obj"
|
||||
".\Debug\device.obj"
|
||||
".\Debug\handlers.obj"
|
||||
".\Debug\iam.obj"
|
||||
".\Debug\npdu.obj"
|
||||
".\Debug\reject.obj"
|
||||
".\Debug\ringbuf.obj"
|
||||
".\Debug\rp.obj"
|
||||
".\Debug\tsm.obj"
|
||||
".\Debug\whois.obj"
|
||||
".\Debug\wp.obj"
|
||||
]
|
||||
Creating command line "link.exe @C:\DOCUME~1\stk01\LOCALS~1\Temp\RSPE12.tmp"
|
||||
<h3>Output Window</h3>
|
||||
Compiling...
|
||||
main.c
|
||||
Linking...
|
||||
|
||||
|
||||
|
||||
<h3>Results</h3>
|
||||
bacnet.exe - 0 error(s), 0 warning(s)
|
||||
</pre>
|
||||
</body>
|
||||
</html>
|
||||
@@ -91,6 +91,11 @@ void bip_set_address(uint8_t octet1, uint8_t octet2,
|
||||
set_network_address(&BIP_Address, octet1, octet2, octet3, octet4);
|
||||
}
|
||||
|
||||
void bip_set_addr(struct in_addr *net_address)
|
||||
{
|
||||
BIP_Address.s_addr = htonl(net_address->s_addr);
|
||||
}
|
||||
|
||||
void bip_set_broadcast_address(uint8_t octet1, uint8_t octet2,
|
||||
uint8_t octet3, uint8_t octet4)
|
||||
{
|
||||
@@ -117,8 +122,6 @@ bool bip_init(void)
|
||||
int value = 1;
|
||||
|
||||
/* local broadcast address */
|
||||
//BIP_Broadcast_Address.s_addr = BIP_Address.s_addr;
|
||||
//BIP_Broadcast_Address.s_addr |= ~(BIP_Subnet_Mask.s_addr);
|
||||
BIP_Broadcast_Address.s_addr = INADDR_BROADCAST;
|
||||
/* configure standard BACnet/IP port */
|
||||
bip_set_port(0xBAC0);
|
||||
@@ -128,6 +131,26 @@ bool bip_init(void)
|
||||
if (BIP_Socket < 0)
|
||||
return false;
|
||||
|
||||
// Allow us to use the same socket for sending and receiving
|
||||
// This makes sure that the src port is correct when sending
|
||||
rv = setsockopt(BIP_Socket, SOL_SOCKET, SO_REUSEADDR,
|
||||
(char *)&value, sizeof(value));
|
||||
if (rv < 0)
|
||||
{
|
||||
close(BIP_Socket);
|
||||
BIP_Socket = -1;
|
||||
return false;
|
||||
}
|
||||
// allow us to send a broadcast
|
||||
rv = setsockopt(BIP_Socket, SOL_SOCKET, SO_BROADCAST,
|
||||
(char *)&value, sizeof(value));
|
||||
if (rv < 0)
|
||||
{
|
||||
close(BIP_Socket);
|
||||
BIP_Socket = -1;
|
||||
return false;
|
||||
}
|
||||
|
||||
// bind the socket to the local port number and IP address
|
||||
sin.sin_family = AF_INET;
|
||||
sin.sin_addr.s_addr = htonl(INADDR_ANY);
|
||||
@@ -167,7 +190,7 @@ static int bip_send(
|
||||
else
|
||||
mtu[1] = 0x0A; /* Original-Unicast-NPDU */
|
||||
mtu_len = 2;
|
||||
mtu_len += encode_unsigned16(&mtu[mtu_len], pdu_len);
|
||||
mtu_len += encode_unsigned16(&mtu[mtu_len], pdu_len + 4 /*inclusive*/);
|
||||
memcpy(&mtu[mtu_len], pdu, pdu_len);
|
||||
mtu_len += pdu_len;
|
||||
|
||||
|
||||
@@ -40,19 +40,16 @@
|
||||
// buffer used for receive
|
||||
static uint8_t Rx_Buf[MAX_MPDU] = {0};
|
||||
|
||||
static BYTE TargetIP[] = {192, 168, 0, 191};
|
||||
static BYTE NetMask[] = {255, 255, 255, 0};
|
||||
|
||||
static void Init_Device_Parameters(void)
|
||||
{
|
||||
// configure my initial values
|
||||
Device_Set_Object_Instance_Number(126);
|
||||
Device_Set_Object_Instance_Number(124);
|
||||
Device_Set_Vendor_Name("Lithonia Lighting");
|
||||
Device_Set_Vendor_Identifier(42);
|
||||
Device_Set_Model_Name("Simple BACnet Server");
|
||||
Device_Set_Model_Name("Simple BACnet Client");
|
||||
Device_Set_Firmware_Revision("1.00");
|
||||
Device_Set_Application_Software_Version("none");
|
||||
Device_Set_Description("Example of a simple BACnet server");
|
||||
Device_Set_Application_Software_Version("win32");
|
||||
Device_Set_Description("Example of a simple BACnet client/server");
|
||||
|
||||
return;
|
||||
}
|
||||
@@ -76,12 +73,31 @@ static void Init_Service_Handlers(void)
|
||||
WritePropertyHandler);
|
||||
}
|
||||
|
||||
/* To fill a need, we invent the gethostaddr() function. */
|
||||
long gethostaddr(void)
|
||||
{
|
||||
struct hostent *host_ent;
|
||||
char host_name[255];
|
||||
|
||||
if (gethostname(host_name, sizeof(host_name)) == 0)
|
||||
return -1;
|
||||
|
||||
if ((host_ent = gethostbyname(host_name)) == NULL)
|
||||
return -1;
|
||||
|
||||
return *(long *)host_ent->h_addr;
|
||||
}
|
||||
|
||||
extern void bip_set_addr(struct in_addr *net_address);
|
||||
|
||||
static void NetInitialize(void)
|
||||
// initialize the TCP/IP stack
|
||||
{
|
||||
int Result;
|
||||
int Code;
|
||||
WSADATA wd;
|
||||
struct in_addr address;
|
||||
|
||||
|
||||
Result = WSAStartup(MAKEWORD(2,2), &wd);
|
||||
|
||||
@@ -92,6 +108,8 @@ static void NetInitialize(void)
|
||||
Code);
|
||||
exit(1);
|
||||
}
|
||||
address.s_addr = gethostaddr();
|
||||
bip_set_addr(&address);
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
@@ -106,8 +124,6 @@ int main(int argc, char *argv[])
|
||||
Init_Service_Handlers();
|
||||
// init the data link layer
|
||||
NetInitialize();
|
||||
bip_set_address(TargetIP[0], TargetIP[1], TargetIP[2], TargetIP[3]);
|
||||
bip_set_address(NetMask[0], NetMask[1], NetMask[2], NetMask[3]);
|
||||
if (!bip_init())
|
||||
return 1;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user