Couldn't resist - here's a modbus wrapper based on
[v0.2.0](https://github.com/nimterop/nimterop/tree/v020) of nimterop still in
test.
For dynamically linking to libmodbus.so:
nim c -d:modbusGit modbus.nim
Run
For static linking:
nim c -d:modbusGit -d:modbusStatic modbus.nim
Run
import os, strutils
import nimterop/[build, cimport]
const
baseDir = currentSourcePath.parentDir()/"build/libmodbus"
static:
cDebug()
getHeader(
"modbus.h",
giturl = "https://github.com/stephane/libmodbus",
outdir = baseDir,
conFlags = "--enable-static=yes --disable-tests"
)
cPlugin:
import strutils
proc onSymbol*(sym: var Symbol) {.exportc, dynlib.} =
sym.name = sym.name.strip(chars = {'_'})
cOverride:
type
modbus = object
when not defined(modbusStatic):
cImport(modbusPath, recurse = true, dynlib = "modbusLPath")
else:
cImport(modbusPath, recurse = true)
Run