Data Loading...

with Visual Studio 2005 Recompiling FieldTalk Modbus Slave ... Flipbook PDF

Recompiling FieldTalk Modbus Slave C++ Library with Visual Studio 2005 AN204-0801 3 •It is recommended to use the same r


107 Views
100 Downloads
FLIP PDF 241.69KB

DOWNLOAD FLIP

REPORT DMCA

Recompiling FieldTalk Modbus Slave C++ Library with Visual Studio 2005 Application Note 204 Revision 1.0, June 2008

Compilation using Visual Studio IDE .......................................................................................................... Changing the compiler settings .................................................................................................................. Compilation using nmake ......................................................................................................................... Trouble shooting the Modbus communication using trace ................................................................................

1 2 4 6

This Application Note describes how to recompile the FieldTalk Modbus Slave C++ Library / Windows Edition with Visual Studio 2005. The product is delivered with a precompiled static library which is ready to be used. Recompilation is only required if your project requires custom settings or modifications. Prerequisites • Visual Studio 2005 Standard or Professional • The Windows Edition of the FieldTalk package must be installed and unzipped on your development computer.

Compilation using Visual Studio IDE The FieldTalk package contains a folder structure similar to this: My Projects fieldtalk doc include src lib win win32 release samples Visual C++ 6.0 Visual Studio 2003 Visual Studio 2005

Directory containing the makefile Directory containing the library file libmbusslave.lib

AN204-0801

1

Recompiling FieldTalk Modbus Slave C++ Library with Visual Studio 2005

Directory containing the Visual Studio 2005 project files to compile the library Open Visual Studio and load the mbusslave_win.sln solution file from the Visual Studio 2005 directory of the FieldTalk package. Select Rebuild Solution from the Build menu.

The compilation starts and the Output window will show a log similar to this: 1>------ Rebuild All started: Project: libmbusslave, Configuration: Release Win3 1>Deleting intermediate and output files for project 'libmbusslave', configurati 1>Compiling... 1>MbusTcpSlaveProtocol.cpp 1>MbusSlaveServer.cpp 1>MbusSerialSlaveProtocol.cpp 1>MbusRtuSlaveProtocol.cpp 1>MbusAsciiSlaveProtocol.cpp 1>hmtimer.cpp 1>hmserio.cpp 1>Generating Code... 1>Compiling... 1>hmhex.c 1>hmcrc16.c 1>BusProtocolErrors.c 1>Generating Code... 1>Creating library... 1>Build log was saved at "file://c:\prj\fieldtalk\cpp.backup\obj\win\Win32\Relea 1>libmbusslave - 0 error(s), 0 warning(s) ========== Rebuild All: 1 succeeded, 0 failed, 0 skipped ==========

The rebuilt library libmbusslave.lib has been placed in the directory lib\win\win32\release, the library include files can be found in the directory include.

Changing the compiler settings Typically some of the following compiler settings may be adjusted depending on your project needs. The following list shows the most common adjustments. • The libraries' character set must match your project's character set. Unless you are targeting Windows 98, you should use Unicode as shown below:

AN204-0801

2

Recompiling FieldTalk Modbus Slave C++ Library with Visual Studio 2005

• It is recommended to use the same runtime library settings for FieldTalk as you use for your main project. Adjust as shown below:

• For backward compatibility with Visual C++ 6.0 the library is compiled with the floating point option /QIFIST set. This setting should be removed with Visual Studio 2005, as it is now deprecated.

AN204-0801

3

Recompiling FieldTalk Modbus Slave C++ Library with Visual Studio 2005

To remove, open the C/C++ Command Line property page and remove the /QIFIST entry as shown below.

Compilation using nmake Open a Visual Studio Command Prompt window from the start menu as shown below.

Change into the src subdirectory of your FieldTalk installation directory: cd c:\proconx\fieldtalk\src

Run nmake from the Visual Studio 2005 Command Prompt window: nmake

The compilation starts and the output will show a log similar to this: C:\proconx\fieldtalk\src>nmake Microsoft (R) Program Maintenance Utility Version 8.00.50727.42 Copyright (C) Microsoft Corporation. All rights reserved. md ..\obj\win\win32\release A subdirectory or file ..\obj\win\win32\release already exists. cl -W4 -I..\src -Fo..\obj\win\win32\release\ -c ..\src\hmlib\common\hm crc16.c ..\src\hmlib\common\hmhex.c ..\src\BusProtocolErrors.c ..\src\hmlib\win

AN204-0801

4

Recompiling FieldTalk Modbus Slave C++ Library with Visual Studio 2005

32\hmtimer.cpp ..\src\hmlib\win32\hmserio.cpp ..\src\MbusSlaveServer.cpp ..\src\ MbusTcpSlaveProtocol.cpp ..\src\MbusSerialSlaveProtocol.cpp ..\src\MbusRtuSlaveP rotocol.cpp ..\src\MbusAsciiSlaveProtocol.cpp Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 14.00.50727.42 for 80x86 Copyright (C) Microsoft Corporation. All rights reserved. hmcrc16.c hmhex.c BusProtocolErrors.c Generating Code... Compiling... hmtimer.cpp hmserio.cpp MbusSlaveServer.cpp MbusTcpSlaveProtocol.cpp MbusSerialSlaveProtocol.cpp MbusRtuSlaveProtocol.cpp MbusAsciiSlaveProtocol.cpp Generating Code... md ..\include A subdirectory or file ..\include already exists. attrib -r ..\include\*.* copy hmlib\common\hmserio.hpp ..\include 1 file(s) copied. copy hmlib\common\hmtimer.hpp ..\include 1 file(s) copied. copy hmlib\common\hmplatf.h ..\include 1 file(s) copied. copy hmlib\common\hmtcpip.h ..\include 1 file(s) copied. copy BusProtocolErrors.h ..\include 1 file(s) copied. copy MbusSlaveServer.hpp ..\include 1 file(s) copied. copy MbusDataTableInterface.hpp ..\include 1 file(s) copied. copy MbusSerialSlaveProtocol.hpp ..\include 1 file(s) copied. copy MbusAsciiSlaveProtocol.hpp ..\include 1 file(s) copied. copy MbusRtuSlaveProtocol.hpp ..\include 1 file(s) copied. copy MbusTcpSlaveProtocol.hpp ..\include 1 file(s) copied. md ..\lib\win\win32\release A subdirectory or file ..\lib\win\win32\release already exists. del ..\lib\win\win32\release\libmbusslave.lib lib.exe -out:..\lib\win\win32\release\libmbusslave.lib ..\obj\win\win32 \release\hmcrc16.obj ..\obj\win\win32\release\hmhex.obj ..\obj\win\win32\release \hmtimer.obj ..\obj\win\win32\release\hmserio.obj ..\obj\win\win32\release\BusPr otocolErrors.obj ..\obj\win\win32\release\MbusSlaveServer.obj ..\obj\win\win32\r elease\MbusTcpSlaveProtocol.obj ..\obj\win\win32\release\MbusSerialSlaveProtocol .obj ..\obj\win\win32\release\MbusRtuSlaveProtocol.obj ..\obj\win\win32\release\ MbusAsciiSlaveProtocol.obj Microsoft (R) Library Manager Version 8.00.50727.42

AN204-0801

5

Recompiling FieldTalk Modbus Slave C++ Library with Visual Studio 2005

Copyright (C) Microsoft Corporation.

All rights reserved.

Library successfully compiled.

The rebuilt library libmbusslave.lib has been placed in the directory lib\win\win32\release, the library include files can be found in the directory include.

Trouble shooting the Modbus communication using trace The library has a tracing feature which logs all communication events and raw data to standard output. To use this trace feature, the library needs to be recompiled with the TRACELOG definition defined. TRACELOG: TRACELOG: TRACELOG: TRACELOG: TRACELOG: TRACELOG: TRACELOG:

Open port: COM1 Parameters: 9600, 8, 1, Configuration: 1000, 0, Frame silence: 5 Read multiple registers Send(6): 01 03 00 63 00 Recv(5): 01 83 01 80 F0

0 0 1 100 0A

Raw data sent on the serial port Raw data received on the serial port In Visual Studio, trace can be enabled by defining the TRACELOG preprocessor definition from the C/C++ Preprocessor property pages as shown below:

Using nmake, TRACELOG can be defined by passing a tracelog parameter (all lower caps) to the makefile as follows:

AN204-0801

6

Recompiling FieldTalk Modbus Slave C++ Library with Visual Studio 2005

nmake tracelog=1

Copyright © 2007-2008 proconX Pty Ltd. All rights reserved. No part of this material may be reproduced or transmitted in any form or by any means or used to make any derivative work without express written consent from the copyright holders. proconX and FieldTalk are trademarks of proconX Pty Ltd. All other product and brand names mentioned in this document may be trademarks or registered trademarks of their respective owners.

Disclaimer proconX Pty Ltd makes no warranty for the use of its products, other than those expressly contained in the Company's standard warranty which is detailed in the Terms and Conditions located on the Company's Website. The Company assumes no responsibility for any errors which may appear in this document, reserves the right to change devices or specifications detailed herein at any time without notice, and does not make any commitment to update the information contained herein. No licenses to patents or other intellectual property of proconX are granted by the Company in connection with the sale of proconX products, expressly or by implication. proconX products are not authorized for use as critical components in life support devices or systems.

Support & product feedback We provide an electronic support and feedback system for our FieldTalk products. It can be accessed through the following web link: http://www.modbusdriver.com/support Your feedback and comments are always welcome. It helps improving this product.

Contact For further information about this document please contact us at: proconX Pty Ltd PO Box 791 Sumner QLD 4074 Australia Website: http://www.proconx.com

AN204-0801

7