Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
ICE-Application/src/ModbusMaster/ModbusMasterApi.cpp
- Committer:
- jmarkel44
- Date:
- 2017-01-24
- Revision:
- 1:b2e90cda7a5a
- Parent:
- 0:61364762ee0e
File content as of revision 1:b2e90cda7a5a:
#include "ModbusMasterApi.h"
#include "ICELog.h"
#include <stdio.h>
bool ModbusMasterReadRegister( const std::string &io_tag, ModbusValue *value )
{
if( !(RegisterValueMap.count(io_tag)) ) {
printf("%s:%d: Key=%s not in Modbus Map\r\n", __func__, __LINE__, io_tag.c_str() );
return false;
}
value->value = RegisterValueMap[io_tag].float_value;
value->errflag = RegisterValueMap[io_tag].errflag;
return true;
}
bool ModbusMasterWriteRegister( const std::string &io_tag, float value )
{
if( !(RegisterValueMap.count(io_tag)) ) {
printf("%s:%d: Key=%s not in Modbus Map\r\n", __func__, __LINE__, io_tag.c_str() );
return false;
}
logDebug("\r[DEBUG] writing tag %s\n", io_tag.c_str());
RegisterValueMap[io_tag].float_value = value;
return true;
}
bool ScriptWriteRegister( const char *io_tag, double value )
{
std::string ioString = io_tag;
if( !(RegisterValueMap.count(ioString)) ) {
printf("%s:%d: Key=%s not in Register Map\r\n", __func__, __LINE__, ioString.c_str() );
return false;
}
logDebug("\r[DEBUG] reading tag %s\n", io_tag);
RegisterValueMap[ioString].float_value = value;
return true;
}
double ScriptReadRegister( const char *io_tag )
{
std::string ioString = io_tag;
if( !(RegisterValueMap.count(ioString)) ) {
printf("%s:%d: Key=%s not in Register Map\r\n", __func__, __LINE__, ioString.c_str() );
return -1;
}
return RegisterValueMap[ioString].float_value;
}