Skip to content
This repository has been archived by the owner on Sep 30, 2021. It is now read-only.

compile error #17

Open
afshin-blue opened this issue Feb 17, 2017 · 1 comment
Open

compile error #17

afshin-blue opened this issue Feb 17, 2017 · 1 comment

Comments

@afshin-blue
Copy link

When i use #include <ModbusMaster.h> from ModbusMaster v2.0.1 sctach does not compile

#include <Bridge.h>
#include <BridgeServer.h>
#include <BridgeClient.h>
#include <ModbusMaster.h>

i got this error:
C:\Program Files (x86)\Arduino\libraries\Bridge\src\Bridge.cpp: In member function 'void BridgeClass::crcUpdate(uint8_t)':

C:\Program Files (x86)\Arduino\libraries\Bridge\src\Bridge.cpp:121:33: error: '_crc_ccitt_update' was not declared in this scope

CRC = _crc_ccitt_update(CRC, c);

i appreciate any sloution

@dmnc-net
Copy link

dmnc-net commented Jul 17, 2017

Hi, I can't believe that this issue is still unresolved. TL;DR: scroll down for the solution.
I've got some points, let me summarize the issue here.

This piece of code can't be compiled in 1.8.3:

#include <Bridge.h>
#include <ModbusMaster.h>
void setup() {}
void loop() {}

because it produces error:
...libraries/Bridge/src/Bridge.cpp:121:33: error: '_crc_ccitt_update' was not declared in this scope

For some reason, it works if you comment out ModbusMaster.h, compile the code and then uncomment the ModbusMaster.h and recompile again. But this is not a clear solution, because a lot of code depends on modbus library (you have to comment out whole project then). Let's go for a real solution:

Bridge.cpp:105 is checking ARDUINO_ARCH_AVR:

#if defined(ARDUINO_ARCH_AVR)
#include <util/crc16.h> // AVR use an optimized implementation of CRC
#else
uint16_t _crc_ccitt_update(uint16_t crc, uint8_t data) // Generic implementation for non-AVR architectures
{
  ...
#endif

With locate and grep I've checked which util/crc16.h contains _crc_ccitt_update() and this function is not found in .../Arduino/libraries/ModbusMaster/src/util/crc16.h. This file just adds crc16_update() in case if _UTIL_CRC16_H_ is not defined but it is not regular crc16.h replacement but somehow prefered during the compilation. Probably @4-20ma should consider this as an issue.

Solution: (hotfix) rename util/crc16.h to something like crc16_.h and modify also ModbusMaster.h:58

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants