PDA

View Full Version : DemoPad Ipad tcp control to Girder - Calling the Guru's!



VicVonDoom
February 8th, 2012, 04:01 PM
Hi Guys,

Just stumbled on a tasty piece of software for the iPad/iPhone called Demopad. www.demopad.com (http://www.demopad.com) (i am in no way affiliated!)

Its a pc GUI designer and an app on the iThingy.
Now here comes the good bit.. It can communicate with other tcp devices...Really Easily...

I've managed to use the example telnet dump example in the girder manual (tiny modifiaction) to listen on a port and print an event in the logger which i can then drag on to any action i like on my gml... Seems to work ok!!

Here's the scripting action (triggered by GirderEnable, Script Enable and the usual startup type events)


--This example demonstrates how to make a dump telnet server


function mycbserver(p1,p2)
if ( p2 == transport.constants.event.CONNECTIONCLOSED ) then
print("Connection Closed")
return
end
if ( p2 == transport.constants.event.NEWCONNECTION ) then
print("New Incoming Connection")
p1:Callback(transport.constants.parser.TERMINATED, '\n', 3000, function (cp1,cp2)
if ( cp2 == transport.constants.event.CONNECTIONCLOSED ) then
print("Client Connection Closed")
p1:Close()
clients[p1]=nil
return
end
if ( cp2 == transport.constants.event.CONNECTIONESTABLISHED ) then
if ( cp1 == 0 ) then
print("New Client Connection")
p1:Write("Telnet Server Live!\r\n")
clients[p1]=true
else
print("New Client Connection Failed: ")
p1:Close()
clients[p1]=nil
end
return
end
print(cp1)
p1:Write(cp1 .. '\r\n')
---------------------------------------
--Added below on 8.2.12 as a test for the logger VicVonDoom--
---------------------------------------
gir.TriggerEvent((cp1 .. '\r\n'), 18, (cp1 .. '\r\n'))
---------------------------------------
end)
return
end
end
if ( clients ) then
for c,v in pairs(clients ) do
c:Close()
end
end
if ( c5 ) then
c5:Close()
end
clients = {}
c5 = transport.New(transport.constants.transport.GIPLIS TEN)
if not c5:Open(nil, 12345) then
print('Could not start listening')
c5:Close();
c5 = nil;
end
c5:Callback(transport.constants.parser.TERMINATED, '\r\n', 1000, mycbserver)
print('Listening for DemoPad connections on port 12345')


I guess this may well answer the whole "we need an iThingy designer argument" for those who do not want to use the webserver or other means.

Is the above code the best way to go about this?
Is there a better simple example i can modify?
I am not a coder (i do the wiring up mostly!) so if anyone can lend a hand with a transport or give an example i can easily butcher, that might be a better approach..?

Forgot to mention it can also receive feedback from devices...

VicVonDoom
February 10th, 2012, 03:48 PM
hmm, quiet round here lately....

Anyhoo, i've borrowed some code from elsewhere to use the new transport based doodah.
Works fine for me!



--Absolutely ripped off of the hard work by promixis forum member 'davedave1234' and the work done to get TouchIR working with Girder!
--tiny mods to this script done by VicVonDoom




function mycbserver(p1,p2)
if ( p2 == transport.constants.event.CONNECTIONCLOSED ) then
print("Connection to DemoPad Closed")
return
end

if ( p2 == transport.constants.event.NEWCONNECTION ) then
print("New Incoming Connection from DemoPad")
p1:Callback(transport.constants.parser.TERMINATED, '\r\n', 3000, function (cp1,cp2)
if ( cp2 == transport.constants.event.CONNECTIONCLOSED ) then
print("DemoPad Client Connection Closed")
p1:Close()
clients[p1]=nil
return
end

if ( cp2 == transport.constants.event.CONNECTIONESTABLISHED ) then
if ( cp1 == 0 ) then
print("New DemoPad Client Connection")
clients[p1]=true
else
print("New DemoPad Connection Failed: ")
p1:Close()
clients[p1]=nil
return
end
end
gir.TriggerEvent((cp1), 18, '')
--print(cp1)
end)
return
end
end
if ( clients ) then
for c,v in pairs(clients ) do
c:Close()
end
end
if ( c5 ) then
c5:Close()
end
clients = {}
c5 = transport.New(transport.constants.transport.GIPLIS TEN)
if not c5:Open(nil, 12345) then
print('Could not start listening for DemoPad connections')
c5:Close();
c5 = nil;
end
c5:Callback(transport.constants.parser.TERMINATED, '\r\n', 1000, mycbserver)
print('Listening for connections from DemoPad on port 12345')


I'm off to start drawing up my ipad pages in a very similar to netremote-designer-styleeeeee!

sirbooker
February 11th, 2012, 11:41 AM
Hi JIm
great find
i havs a iphone and have been wanting to get an ipad for some time now.
i would like to try this out but don't understand where to put the above code ( demopad.lua)
would you mind giving me some guidence to get started.

i am surprised that no one else has piped in on this.

thanks Paul.

VicVonDoom
February 11th, 2012, 01:24 PM
should hopefully have some time (and fixed broadband) tomo for a how-to guide for both girder and demopad... I'll be including some screenshots etc...

pfeifer
February 13th, 2012, 05:45 PM
It's possible use the domopad lite version?

VicVonDoom
February 13th, 2012, 06:10 PM
demopad lite' is more of a proof of layout tool and does not actually send any commands.
you need to have 'demopad' for actual use.

VicVonDoom
February 15th, 2012, 03:00 PM
The HowTo is located here.... http://www.promixis.com/forums/showthread.php?21338-Howto-DemoPad-to-Girder