問題
4diac 項目的更新真的是個問題。沒有對所有的模塊完成測試。在forte 1.12.0 版本上編譯就出現了問題。4diac 的論壇上討論的比較少,而且大多數是早幾年的內容。沒辦法,只能自己啃源代碼。
編譯的問題。
1.modbustimedevent.cpp 的36 行
m_oStartTime = CTimerHandler::sm_poFORTETimer->getForteTime();
2 modbustimedevent 45 行
SForteTime currentTime = CTimerHandler::sm_poFORTETimer->getForteTime();
中:sm_poFORTETimer 沒有定義。
解決方法
參照了forte 1.10.3 版本:
1 modbusplayer.cpp 的363 行,getExtEvHandler的前面加了一個&改爲:
m_pModbusConnection = new CModbusClientConnection(&getExtEvHandler<CModbusHandler>());
2 modbustimedevent.h 中
uint_fast64_t m_oStartTime;
uint_fast64_t m_oUpdateInterval;
3 modbustimedevent.cpp 的36 行改爲
m_oStartTime = CTimerHandler::smFORTETimer->getForteTime();
modbustimedevent 45 行 改爲
uint_fast64_t currentTime =CTimerHandler::smFORTETimer->getForteTime();
4 在 arch/timerha.h 中添加了
static CTimerHandler *smFORTETimer;
在 arch/timeha.cpp 中添加了
CTimerHandler *CTimerHandler::smFORTETimer = 0;
5 這是定義了一個指向CTimerHandle類的指針,但是需要填入資源真正的handler ,不然就一直出現段錯誤。找了好久。在
在core/devexec.cpp 中構造函數中添加了
CTimerHandler::smFORTETimer= static_cast<CTimerHandler*>(mRegisteredEventHandlers[0].mHandler);
結果好了。
6 使用4diac 的client 功能塊。
ID modbus[tcp:127.0.0.1:502:1000:3:1:0..3:]
7 SForteTime 類型不兼容,可以改爲 uint_fast64_t 。例如 uint_fast64_t m_oStartTime; uint_fast64_t m_oUpdateInterval;
測試
寫寄存器,forte 自動將 功能碼06 轉成了16.
modbus[tcp:127.0.0.1:502:1000:6:1::0:]
讀寄存器
modbus[tcp:127.0.0.1:502:1000:3:1:0:0..1:]