Arduino Library functions generate error on lua script

Support for Arduino in combination with Air Manager and Air Player

Moderators: russ, Ralph

Post Reply
Message
Author
ZioZanna
Posts: 67
Joined: Wed Jul 26, 2017 8:49 pm

Arduino Library functions generate error on lua script

#1 Post by ZioZanna »

Good morning

I did follow the wiki on https://siminnovations.com/wiki/index.p ... #Installer in order to use hw_... library to send and receive message from arduino

No problem to compile the skecth and send it to arduino; the problem is on lua thats stops with error because the hw_... functions does not exists

here the code
function new_message(id, payload)
print("received new message with id " .. id)
end

msgprt = hw_message_port_add("ARDUINO_UNO_B", new_message)
ERROR - Error loading instrument script: logic.lua [string "logic.lua"]:15: attempt to call a nil value (global 'hw_message_port_add')

same when I call
hw_message_port_send(msgprt, 777, nil, 0)
ERROR - error in hardware button pressed callback: [string "logic.lua"]:51: attempt to call a nil value (global 'hw_message_port_send')

Any helps?

Thanks

SimPassion
Posts: 5346
Joined: Thu Jul 27, 2017 12:22 am

Re: Arduino Library functions generate error on lua script

#2 Post by SimPassion »

Hello ZioZanna

could it be that the hw_message_port_add need also a port number ?
as here : viewtopic.php?p=6764#p6764

in reference :
https://siminnovations.com/wiki/index.p ... re_id_list
https://siminnovations.com/wiki/index.p ... I#Hardware

Gilles

ZioZanna
Posts: 67
Joined: Wed Jul 26, 2017 8:49 pm

Re: Arduino Library functions generate error on lua script

#3 Post by ZioZanna »

Thanks Gilles

As far as i understand don't Think that the funcs require a specific port because the library functions are referring to a dedicated Arduino as in the Wiki lua exsample

The error generated in tipical of a non declarated function.
-- This function will be called when a message is received from the Arduino.
function new_message(id, payload)
-- Do something with the message from the Arduino
end

id = hw_message_port_add("ARDUINO_MEGA2560_A", new_message)

-- Send a message to the Arduino with id 777 and 3 bytes as payload (0x01, 0x02, 0x03)
hw_message_port_send(id, 777, [ 1, 2, 3 ])
Andrea

SimPassion
Posts: 5346
Joined: Thu Jul 27, 2017 12:22 am

Re: Arduino Library functions generate error on lua script

#4 Post by SimPassion »

I have no more idea as i've not work this way for the moment (with a sketch)
but rather with Arduino Installer having good results for now on my own

i think the community will help better than i could for this

Best regards
Gilles

User avatar
Sling
Posts: 5242
Joined: Mon Sep 11, 2017 2:37 pm
Contact:

Re: Arduino Library functions generate error on lua script

#5 Post by Sling »

What version of AM do you have? You need at least 3.1 to use those functions. It looks as though you are trying to call API functions that do not exist in your version of AM. Installing the latest beta should fix it.

ZioZanna
Posts: 67
Joined: Wed Jul 26, 2017 8:49 pm

Re: Arduino Library functions generate error on lua script

#6 Post by ZioZanna »

Correct :D :D :D , upgrading to latest AM3.2 the error goes away.

Still have problems in communication between AM3.2 and ARDUINO UNO as in this new thread

viewtopic.php?f=35&t=858

many thanks for your help

Post Reply