Coremoter: a simulator helper

I used to post this article in Subscribers Only forum.
But coremoter can be used by born subscribers and common users.
You can download it from:
http://itunes.apple.com/us/app/coremoter/id465045046

Before your downloading, you can watch following videos to roughly learn how coremoter can do.
Demo videos:
on youtube.com (USA):
http://www.youtube.com/watch?v=gI_kqk05z8k
http://www.youtube.com/watch?v=FZFkz1Ho5bA
http://www.youtube.com/watch?v=WKbnPHx9JkI
http://www.youtube.com/watch?v=Wxzeg2ytxVI
http://www.youtube.com/watch?v=Wwh_EB3x5us

on youku.com (China):
http://www.youku.com/playlist_show/id_15431266.html
http://v.youku.com/v_show/id_XMzAzNzQyMTM2.html
http://v.youku.com/v_show/id_XMzAzNzQ0MjEy.html
http://v.youku.com/v_show/id_XMzAzNzQ1MzIw.html
http://v.youku.com/v_show/id_XMzAzNzQ1OTU2.html
http://v.youku.com/v_show/id_XMzAzNzQ3MDU2.html

Coremoter is a development utility for corona SDK.
It helps corona developers testing their programs in corona simulator with accelerometer events and tuner events(or you must build the app for device and test it on device).
It has a wonderful feature: you can create a fake input textfield in simulator. By touching the fake inputfield, a real inputfield will be actived on the coremoter’s screen (on your device) so you can test your input and really changes the text in simulator.
It also supports multitouch on device, so you can test your app’s multitouch feature in simulator by touching your device.
It can save a lot of your building and testing time.
Coremoter sends all events over wifi. It support’s both UDP and TCP protocol. UDP is for fast event transmission. TCP is for testing when you do not have a device or you want to make some specific event by hand :slight_smile: (That means, by TCP protocol, you can telnet to the simulator and input the event string you wanted to generate a accelerometer event or tuner event)

You can try it for FREE by downloading this lite version:
http://itunes.apple.com/us/app/coremoterlite/id455625403
It has full feature except for some activation count limits.
The unlimited version can be downloaded from here:
http://itunes.apple.com/us/app/coremoter/id465045046

How to test

  1. download the latest corona SDK from : http://developer.anscamobile.com/downloads/coronasdk
    you need a corona account, just register one. It’s easy.
    after downloading, you should install it to your mac.
  2. then get lua source code at google code by subversion:
    svn checkout http://coremoter.googlecode.com/svn/trunk/ coremotertst
    (you can also downlaod the lastest package from: http://code.google.com/p/coremoter/downloads/list and extract files into a directory named “coremotertst”)
  3. run the corona simulator and load the main.lua from the directory coremotertst
  4. run the coremoter app on your device
  5. touch TCP button to change it to UDP
  6. press connect
  7. enter the server IP (which is your mac’s ip)
  8. press the OK button ( the green hook button)
  9. then press the buttons from “off” to “on” to see the effects in the corona simulator.
    (shake or change pose or shout at your device)

Important information:
At begin of remoter.lua, there is a detailed description about usage of this code

Following are some examples about how to modify Corona SDK Sample Code to accept events from coremoter.
You will find it is very easy.

  1. DebugDraw
    copy the files (remoter.lua, whnet.lua, base64.lua) to DebugDraw source code directory

in main.lua

add following code at the beginning of file

require(“remoter”)
remoter.startService(“udp”, 1974)

find
j:addEventListener( “touch”, dragBody )

change it to following:
function j:touch(event)
dragBody(event)
end
j:addEventListener( “touch”, j )

then, run it in simulator
open coremoter
connect to youreip:1974
turn multitouch on

  1. ShapeTumbler
    copy the files (remoter.lua, whnet.lua, base64.lua) to ShapeTumbler source code directory

in main.lua

add following code at the beginning of file

require(“remoter”)
remoter.startService(“udp”, 1974)
[import]uid: 35642 topic_id: 18394 reply_id: 318394[/import]

Interesting work! [import]uid: 105123 topic_id: 18394 reply_id: 70990[/import]

New year discount to 1.99$ now :slight_smile: [import]uid: 35642 topic_id: 18394 reply_id: 76882[/import]

Did you write the coremoter app in Corona?
I have been using your app and I cant get my getVolume updates to work as fast as they do in the simulator.
When using Coremoter I see about 5 volume updates a second, with hardware I’m seeing just 2?

It’s a great app and thank you for your hard work.
Brad [import]uid: 110373 topic_id: 18394 reply_id: 76895[/import]

Yes, I am the maker of coremoter. Thank you for using my app :slight_smile:
In fact, coremoter sends volume updates at a frame rate of 30/sec.
If you add following line at line 266 in coremoter.lua,

 , tuner =  
 function (event)  
 g\_TunerFrequency = tonumber(event.Frequency)  
 g\_TunerVolume = tonumber(event.Volume)  
print("\*\*\*\*", system.getTimer(), g\_TunerFrequency, g\_TunerVolume)  
 end  

Run you app in simulator and coremoter on your device (of cause you should turn Tuner to “On” in coremoter), you will find the update rate in simulator.

I made a test and find that the actual tuner data is updated at a frame rate of 10/sec. You will find this in the output window, because some consequent lines are the same.

I think as long as you are using remoter.getTunerFrequency() and remoter.getTunerVolume() to get tuner data, the updating rate will be always about 10/sec.
You can print the them in the enterFrame event and find out yourself.

Best regards and Happy 2012 :wink:
[import]uid: 35642 topic_id: 18394 reply_id: 77442[/import]

I do get the 10 samples from coremoter but on device builds I’m still only seeing 2.
Did you write the “coremoter” app with corona?
if so what build did you use, trying to track down if this is mabye a new issue since the “Simple Tuner” code from Ansca only seems to have 2 samples a second as well.

I get very different values from remoter.getTunerVolume() and r:getTunerVolume()

Below is some test code that shows the slow response issues on hardware

from coremoter app running connected to this app in the simulator i see -35 to -10 sound range and 5 or 6 samples
from this app on it’s own as hardware (iphone 4) i see -122 to -130 and just 2 samples

main.lua
[lua]local isSimulator = “simulator” == system.getInfo(“environment”)
print ("Simulator ",isSimulator)
local remoter = require(“remoter”)
print("startService: "…tostring(remoter.startService(“udp”, 1974)))
r = media.newRecording()
r:startRecording()
r:startTuner()
lastSec = -1
cnt = -1
useSound = true
vdisp = display.newText(“Volume Readout” , 24,100,nil, 14)
volume = display.newText( “foo”, 100, 150, nil, 20 )
function volumeP( event ) --volume:enterFrame

if useSound then

local vol
if (isSimulator == true) then
vol = remoter.getTunerVolume()
else
vol = r:getTunerVolume()
end
local v = 20*math.log(vol)
local date = os.date( “*t” ) – returns table of date & time values – print year and month
if date.sec == lastSec then
else
cnt = 0
end

if lastvol == vol then

else
cnt = cnt + 1
volume.text = cnt … " : " … " : " … date.sec … " : " … string.format("%4.2f", v )

end
lastSec = date.sec
lastvol = vol
end
end

Runtime:addEventListener( “enterFrame”, volumeP );[/lua] [import]uid: 110373 topic_id: 18394 reply_id: 77505[/import]

Yes, I wrote coremoter with Corona SDK (I even wrote it with my remoter.lua :slight_smile:

You should change:
if (isSimulator == true) then
vol = remoter.getTunerVolume()
else
vol = r:getTunerVolume()
end

to
vol = remoter.getTunerVolume()

remoter.startTuner() should be called before at the begining of your code.

I wrapped every function inside remoter.lua, so you need no modification for your code to build for device.
[import]uid: 35642 topic_id: 18394 reply_id: 77716[/import]

I changed the code like you said and that did fix one of my issues. I now get 6 samples on the phone hardware. However the values of “vol” are very different when in the simulator vs hardware. [import]uid: 110373 topic_id: 18394 reply_id: 77936[/import]

mac’s ip?

How do you find your mac’s ip?

Do you have to do anything with sharing? [import]uid: 6288 topic_id: 18394 reply_id: 77953[/import]

mobilefun4me:
open network preferences, click airport or ethernet (which ever you use) IP is written in the status field. [import]uid: 110373 topic_id: 18394 reply_id: 77969[/import]

Connection to ip address failed

Yes, I put in the ip address per your instructions but still get the above error message. I’m wondering about the Port? It defaults to 1974. Is there a way to look up the correct port that I should use?

Err: timeout [import]uid: 6288 topic_id: 18394 reply_id: 77983[/import]

@mobilefun4me
Did you forget to open wifi on your device on which coremoter is running? I sometime made such mistakes :stuck_out_tongue:

If you still have connection problems, please check the simulator output.
If you can find:
**** starting UDP server …
**** startServer at port:1974 rst:true
at the begining, it means that the service is started OK.

You can use
remoter.startService(“udp”, yourport)
to assign a different port to listen as you wish.
You can also use
remoter.startService(“tcp”, yourport)
to use tcp protocol, and use
telnet yourip yourport
to test if the yourport is in service.

btw, you can also find your mac’s ip by running ifconfig at your terminal.
[import]uid: 35642 topic_id: 18394 reply_id: 78017[/import]