From 1bafe2ed9887292ae5e7715fefc947928a80de3b Mon Sep 17 00:00:00 2001 From: skarg Date: Thu, 20 May 2010 23:31:50 +0000 Subject: [PATCH] Added all standard baud rates for Windows serial ports. Updated mstpcap readme file. --- bacnet-stack/demo/mstpcap/mstpcap.txt | 36 +++++-------------- bacnet-stack/ports/win32/rs485.c | 52 ++++++++++++++++++++++++++- 2 files changed, 60 insertions(+), 28 deletions(-) diff --git a/bacnet-stack/demo/mstpcap/mstpcap.txt b/bacnet-stack/demo/mstpcap/mstpcap.txt index 5001a1df..b9a223bd 100644 --- a/bacnet-stack/demo/mstpcap/mstpcap.txt +++ b/bacnet-stack/demo/mstpcap/mstpcap.txt @@ -7,13 +7,6 @@ code in it, and will contain up to 65535 packets. A new file will be created at each 65535 packet interval. The tool can be stopped by using Control-C. -Wireshark is a protocol anaylzyer that can be downloaded from -wireshark.org. Wireshark can open and view the files that -are created from mstpcap. Wireshark can also open a named -pipe, and msptcap can send the capture data to the named pipe -for realtime viewing, while saving the capture data to a file. -See Named Pipe Usage below. - Here is a sample of the tool running (use CTRL-C to quit). D:\code\bacnet-stack\bin>mstpcap COM3 38400 Adjusted interface name to \\.\COM3 @@ -24,8 +17,6 @@ MAC MaxMstr Tokens Retries Treply Tusage Trpfm Tder Tpostpd 0 0 525 0 32 0 0 0 0 1 127 525 0 16 79 0 0 0 -Statistics ----------- The BACnet MS/TP capture tool also includes statistics which are listed for any MAC addresses found passing a token, or any MAC address replying to a DER message. @@ -62,23 +53,14 @@ required to be less than 250ms. Note that the mstpcap tool may not have that good of resolution on Windows, so timing under 50ms may not be accurate. -Name Pipe Usage ---------------- -1. Launch the mstpcap with all command line options, include the named -pipe. On Linux, the named pipe can be any file. On Windows the named -pipe must be located in a specific directory \\.\pipe\wireshark +Note: If you are using FTDI chip in your RS485 converter, you can +alias an existing baud rate on Windows in the FTDIPORT.INF file +in order to acheive non-standard 76800 bps: +HKR,,"ConfigData",1,11,00,3F,3F,27,C0,00,00,27,00,00,00,C4,09,00,00,E2,04,00,00,71,02,00,00,38,41,00,00,9C,80,00,00,4E,C0,00,00,34,00,00,00,1A,00,00,00,0D,00,00,00,06,40,00,00,03,80,00,00,00,00,00,00,D0,80,00,00 -D:\code\bacnet-stack\bin>mstpcap COM3 38400 \\.\pipe\wireshark +replace the 10,27,00,00 => divisor = 10000, rate = 300 bps alias -2. Run Wireshark. Select "Capture" -> "Options" -> "Interface". Copy the -pipe name from the command console (i.e. Mark) and paste it into the -Interface box. Select "Start" to begin the live capture. Note that -the capture cannot be restarted from Wireshark, but must be restarted from -the command line each time you want to capture. - -Non-Standard Baud Rates ------------------------ -If your serial adapter supports non-standard baud rates by using -aliasing, you can pass the aliased buad rate as the baud rate -parameter. 76800 is a non-standard baud rate, and is not enumerated -on Windows Computers. +hex values actual +----------- --------- +27,C0,00,00 - 76923 bps => divisor=39.125 +27,00,00,00 - 76677 bps => divisor=39.000 diff --git a/bacnet-stack/ports/win32/rs485.c b/bacnet-stack/ports/win32/rs485.c index c272d9dd..1ed35e81 100644 --- a/bacnet-stack/ports/win32/rs485.c +++ b/bacnet-stack/ports/win32/rs485.c @@ -269,8 +269,28 @@ uint32_t RS485_Get_Baud_Rate( return 57600; case CBR_115200: return 115200; - default: + case CBR_110: + return 110; + case CBR_300: + return 300; + case CBR_600: + return 600; + case CBR_1200: + return 1200; + case CBR_2400: + return 2400; + case CBR_4800: + return 4800; + case CBR_14400: + return 14400; + case CBR_56000: + return 56000; + case CBR_128000: + return 128000; + case CBR_256000: + return 256000; case CBR_9600: + default: return 9600; } } @@ -302,6 +322,36 @@ bool RS485_Set_Baud_Rate( case 115200: RS485_Baud = CBR_115200; break; + case 110: + RS485_Baud = CBR_110; + break; + case 300: + RS485_Baud = CBR_300; + break; + case 600: + RS485_Baud = CBR_600; + break; + case 1200: + RS485_Baud = CBR_1200; + break; + case 2400: + RS485_Baud = CBR_2400; + break; + case 4800: + RS485_Baud = CBR_4800; + break; + case 14400: + RS485_Baud = CBR_14400; + break; + case 56000: + RS485_Baud = CBR_56000; + break; + case 128000: + RS485_Baud = CBR_128000; + break; + case 256000: + RS485_Baud = CBR_256000; + break; default: valid = false; break;