Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [mihini-dev] problem on modbus

Another tip : I think the address between the arduino modbus and mihini are shifted of 1.


On Wed, Apr 24, 2013 at 12:04 AM, Benjamin Cabé <bcabe@xxxxxxxxxxxxxxxxxx> wrote:
Yong-Jie,

For a reason I ignore (bug in the Arduino Modbus stack or in Mihini), it might help if you put a small delay between the moment you create the modbus client and the moment you try reading registers:

modbus_client = modbus.new(MODBUS_PORT, MODBUS_CONF)
log(LOG_NAME, "INFO", "Modbus      - OK")
sched.wait(2)
while true do
  local values = modbus_client:readHoldingRegisters(1,0,9)
  print(values)
  sched.wait(5)
end

Cheers,
Benjamin-- 


De : <He>, Yong-Jie <334627855@xxxxxx>
Répondre à : Mihini project developer discussions <mihini-dev@xxxxxxxxxxx>
Date : mardi 23 avril 2013 17:45
À : mihini-dev <mihini-dev@xxxxxxxxxxx>
Objet : [mihini-dev] problem on modbus

Hi,

I am trying to get data via modbus on mihini.

This is the program upload into Arduino:

This is the program running in the mihini:

local sched  = require 'sched'
local modbus = require 'modbus'

local MODBUS_PORT = "/dev/ttyACM0" -- serial port on RaspPi
local MODBUS_CONF = {baudRate = 9600 }

local LOG_NAME = "MODBUS_APP"

local function main()
  log.setlevel("INFO")
log(LOG_NAME, "INFO", "Application started")
modbus_client = modbus.new(MODBUS_PORT, MODBUS_CONF)
log(LOG_NAME, "INFO", "Modbus      - OK")
while true do
local values = modbus_client:readHoldingRegisters(1,0,9)
print(values)
sched.wait(5)
end
  
end

sched.run(main)
sched.loop()


When I run this lua program, this is the output:

Tue Apr 23 15:37:02 2013 MODBUS_APP-INFO: Application started
Tue Apr 23 15:37:02 2013 MODBUS_APP-INFO: Modbus      - OK
nil
nil
nil
nil
nil
nil
nil
nil
nil
nil
Tue Apr 23 15:38:03 2013 MODBUS-WARNING: Failure while processing a request: timeout



Can anyone give me some idea?

Best Reagrds
Yong-Jie




_______________________________________________
mihini-dev mailing list
mihini-dev@xxxxxxxxxxx
http://dev.eclipse.org/mailman/listinfo/mihini-dev



Back to the top