How to call irsend

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
32 messages Options
12
Reply | Threaded
Open this post in threaded view
|

How to call irsend

Louis LaBrunda
Hi Guys,

I would like to call irsend (a program that is part of lirc package) from
Squeak on the Raspberry Pi.  Can anyone please post some sample code.

Lou
-----------------------------------------------------------
Louis LaBrunda
Keystone Software Corp.
SkypeMe callto://PhotonDemon
mailto:[hidden email] http://www.Keystone-Software.com


Reply | Threaded
Open this post in threaded view
|

Re: How to call irsend

David T. Lewis
On Mon, Feb 04, 2013 at 02:07:12PM -0500, Louis LaBrunda wrote:
> Hi Guys,
>
> I would like to call irsend (a program that is part of lirc package) from
> Squeak on the Raspberry Pi.  Can anyone please post some sample code.
>

I'm not familiar with it myself, but if irsend is just a simple command line
program then I should think that you could call it easily using OSProcess.

Dave


Reply | Threaded
Open this post in threaded view
|

How to call irsend

Louis LaBrunda
Hi Dave,

Thanks for the reply.  OSProcess sounds like it is what I need but I can't
find any install instructions, probably because I don't know much about
Squeak and Linux and I'm not sure where to look.

Lou

>On Mon, Feb 04, 2013 at 02:07:12PM -0500, Louis LaBrunda wrote:
>> Hi Guys,
>>
>> I would like to call irsend (a program that is part of lirc package) from
>> Squeak on the Raspberry Pi.  Can anyone please post some sample code.
>>
>
>I'm not familiar with it myself, but if irsend is just a simple command line
>program then I should think that you could call it easily using OSProcess.
>
>Dave
>
>
-----------------------------------------------------------
Louis LaBrunda
Keystone Software Corp.
SkypeMe callto://PhotonDemon
mailto:[hidden email] http://www.Keystone-Software.com


Reply | Threaded
Open this post in threaded view
|

Re: How to call irsend

David T. Lewis
On Tue, Feb 05, 2013 at 03:55:14PM -0500, Louis LaBrunda wrote:

>
> >On Mon, Feb 04, 2013 at 02:07:12PM -0500, Louis LaBrunda wrote:
> >> Hi Guys,
> >>
> >> I would like to call irsend (a program that is part of lirc package) from
> >> Squeak on the Raspberry Pi.  Can anyone please post some sample code.
> >>
> >
> >I'm not familiar with it myself, but if irsend is just a simple command line
> >program then I should think that you could call it easily using OSProcess.
> >
>
> Thanks for the reply.  OSProcess sounds like it is what I need but I can't
> find any install instructions, probably because I don't know much about
> Squeak and Linux and I'm not sure where to look.
>

Open a SqueakMap Package Loader:

  world -> open... -> SqueakMap Catalog

In the SqueakMap Package Loader, select package OSProcess. Expand that
category and you will find entries for version 4.4.11 and for "head".
Either one is fine, but I usually recommend just using the latest version,
so select "head" and install it.

Assuming that you want to run irsend with some command line parameters,
try inspecting the following expression (but use some command parameters
that actually do something):

  OSProcess command: 'irsend foo bar baz'

The result will be an instance of ExternalUnixOSProcess that is a proxy
for the actual irsend program that you just executed. You can send it
#succeeded to see if the command was evaluated without error.

I think this is sufficient for what you are trying to do, but you can also
do fancier things with external programs if you load CommandShell (also
on SqueakMap).

For additional background see http://wiki.squeak.org/squeak/708 and
http://wiki.squeak.org/squeak/1914.

Follow up questions welcome :)

Dave


Reply | Threaded
Open this post in threaded view
|

How to call irsend

Louis LaBrunda
Hey Dave,

Again, many thanks for the reply.  Your instructions worked great and so
did my test of the irsend command.

Lou

>Open a SqueakMap Package Loader:
>
>  world -> open... -> SqueakMap Catalog
>
>In the SqueakMap Package Loader, select package OSProcess. Expand that
>category and you will find entries for version 4.4.11 and for "head".
>Either one is fine, but I usually recommend just using the latest version,
>so select "head" and install it.
>
>Assuming that you want to run irsend with some command line parameters,
>try inspecting the following expression (but use some command parameters
>that actually do something):
>
>  OSProcess command: 'irsend foo bar baz'
>
>The result will be an instance of ExternalUnixOSProcess that is a proxy
>for the actual irsend program that you just executed. You can send it
>#succeeded to see if the command was evaluated without error.
>
>I think this is sufficient for what you are trying to do, but you can also
>do fancier things with external programs if you load CommandShell (also
>on SqueakMap).
>
>For additional background see http://wiki.squeak.org/squeak/708 and
>http://wiki.squeak.org/squeak/1914.
>
>Follow up questions welcome :)
>
>Dave
>
>
-----------------------------------------------------------
Louis LaBrunda
Keystone Software Corp.
SkypeMe callto://PhotonDemon
mailto:[hidden email] http://www.Keystone-Software.com


Reply | Threaded
Open this post in threaded view
|

Re: How to call irsend

timrowledge

On 05-02-2013, at 3:15 PM, Louis LaBrunda <[hidden email]> wrote:

> Hey Dave,
>
> Again, many thanks for the reply.  Your instructions worked great and so
> did my test of the irsend command.

Now you just owe us an explanation of what you're getting up to with your Pi; irsend sounds like maybe doing an IR remote control thingy? Nosy buggers need to know...


tim
--
tim Rowledge; [hidden email]; http://www.rowledge.org/tim
A)bort, R)etry, I)nfluence with large hammer.



Reply | Threaded
Open this post in threaded view
|

How to call irsend

Louis LaBrunda
Hi Tim,

>Now you just owe us an explanation of what you're getting up to with your Pi; irsend sounds like maybe doing an IR remote control thingy? Nosy buggers need to know...

Glad you asked.  I know, you know a lot of what I'm about to say here but
it may help other Nosy buggers.

I have a very old Windows 2000 computer (I call it the TV computer, it is
cobble together from old parts, one of which came from a neighbor kid who
bent the CPU pins pulling it out to upgrade the motherboard and CPU) that I
use to record some TV shows in the evening.  It is (and has to be)
connected to a cable box.  To record different channels as the night goes
on, the cable box channel needs to be changed at the right time.  This
tried to do this from the TV computer but it is too old and slow to record
and change the channels reliably at the same time.  Enter the Raspberry Pi
http://www.raspberrypi.org/.

I use an IR transmitter I got from Iguanaworks http://iguanaworks.net and
LIRC http://www.lirc.org/ (there is also a Windows version at
http://winlirc.sourceforge.net/) to send it commands to change the channel.
I was using the Iguana from an other Windows computer but that is a lot of
horsepower just to change the channels.

I use Raspbian (http://www.raspbian.org/ a Debian version of Linux) because
I felt it would be easier to run Squeak and the LIRC code.  I wrote a class
to hold the IguanaIR/LIRC info to change the channel at a given time and
reschedule for another day.  It considers things like the individual
weekdays and all weekdays.

LIRC has a command called irsend that (after some set up) can send a
request to the IguanaIR to send some IR codes, like change the channel.
Dave's "OSProcess command:" works great to run the irsend command with data
from my class to change the channel.

I plan to write code in a workspace that will instantiate this class for
each time I need to change the channel during the week.  These instances
will be put in a collection that is run through every second or so to see
if it is time to change the channel.  I expect to start Squeak on the
RasPi, load the workspace, start it up and leave it running.  At least
until I want to play with the RasPi for something else.

Lou
-----------------------------------------------------------
Louis LaBrunda
Keystone Software Corp.
SkypeMe callto://PhotonDemon
mailto:[hidden email] http://www.Keystone-Software.com


Reply | Threaded
Open this post in threaded view
|

How to call irsend

Louis LaBrunda
In reply to this post by David T. Lewis
Hi Dave,

Last night I left the RasPi running my Squeak code to change the channels.
Most worked just fine.  One of the calls to "OSProcess command:..." says it
had a "... normal termination with status 1".  It didn't change the
channel.  I will look through the code for what this and other status codes
mean but can you tell me or point me to some docs.

I would like to test for errors and retry.  For now I think I will just
test for non zero.

Lou

On Tue, 5 Feb 2013 17:22:50 -0500, "David T. Lewis" <[hidden email]>
wrote:

>On Tue, Feb 05, 2013 at 03:55:14PM -0500, Louis LaBrunda wrote:
>>
>> >On Mon, Feb 04, 2013 at 02:07:12PM -0500, Louis LaBrunda wrote:
>> >> Hi Guys,
>> >>
>> >> I would like to call irsend (a program that is part of lirc package) from
>> >> Squeak on the Raspberry Pi.  Can anyone please post some sample code.
>> >>
>> >
>> >I'm not familiar with it myself, but if irsend is just a simple command line
>> >program then I should think that you could call it easily using OSProcess.
>> >
>>
>> Thanks for the reply.  OSProcess sounds like it is what I need but I can't
>> find any install instructions, probably because I don't know much about
>> Squeak and Linux and I'm not sure where to look.
>>
>
>Open a SqueakMap Package Loader:
>
>  world -> open... -> SqueakMap Catalog
>
>In the SqueakMap Package Loader, select package OSProcess. Expand that
>category and you will find entries for version 4.4.11 and for "head".
>Either one is fine, but I usually recommend just using the latest version,
>so select "head" and install it.
>
>Assuming that you want to run irsend with some command line parameters,
>try inspecting the following expression (but use some command parameters
>that actually do something):
>
>  OSProcess command: 'irsend foo bar baz'
>
>The result will be an instance of ExternalUnixOSProcess that is a proxy
>for the actual irsend program that you just executed. You can send it
>#succeeded to see if the command was evaluated without error.
>
>I think this is sufficient for what you are trying to do, but you can also
>do fancier things with external programs if you load CommandShell (also
>on SqueakMap).
>
>For additional background see http://wiki.squeak.org/squeak/708 and
>http://wiki.squeak.org/squeak/1914.
>
>Follow up questions welcome :)
>
>Dave
>
>
-----------------------------------------------------------
Louis LaBrunda
Keystone Software Corp.
SkypeMe callto://PhotonDemon
mailto:[hidden email] http://www.Keystone-Software.com


Reply | Threaded
Open this post in threaded view
|

Re: How to call irsend

David T. Lewis
There are a couple of ways that a unix program can provide error output.
The exit status is a simple way to communicate either success, or one of
possibly several not so successful outcomes. This is useful for programs
that are used in shell scripts for example. The other way is for the
program to write error messages to its stderr output stream. This is
common for programs for which which a user is expected to read the error
messages.

I don't see anything in the man page for irsend that explains the exit
status values, so it's a good bet that 0 means goodness and anything
else means not so good. That might not be enough information to change
the channel on your TV, but as you say I'd go ahead and try that first
and see if it is good enough.

If you need to read the error output from the stdout stream (i.e. the
error messages that would normally go to the console when you run
the irsend program), you can do this by loading the CommandShell
package from SqueakMap, then do something like this:

irsend := ProxyPipeline command: 'irsend foo bar baz'.

irsend last processProxy ==> an ExternalUnixOSProcess with pid 4157 on /usr/bin/irsend (complete, normal termination with status 1)

irsend errorUpToEnd ==> 'irsend: could not connect to socket
irsend: No such file or directory
'

But I think this is more complexity than you really need for this, so
definitely you should first try just checking for exit status 0 and see
if that does what you need.

Dave


On Thu, Feb 07, 2013 at 11:37:17AM -0500, Louis LaBrunda wrote:

> Hi Dave,
>
> Last night I left the RasPi running my Squeak code to change the channels.
> Most worked just fine.  One of the calls to "OSProcess command:..." says it
> had a "... normal termination with status 1".  It didn't change the
> channel.  I will look through the code for what this and other status codes
> mean but can you tell me or point me to some docs.
>
> I would like to test for errors and retry.  For now I think I will just
> test for non zero.
>
> Lou
>
> On Tue, 5 Feb 2013 17:22:50 -0500, "David T. Lewis" <[hidden email]>
> wrote:
>
> >On Tue, Feb 05, 2013 at 03:55:14PM -0500, Louis LaBrunda wrote:
> >>
> >> >On Mon, Feb 04, 2013 at 02:07:12PM -0500, Louis LaBrunda wrote:
> >> >> Hi Guys,
> >> >>
> >> >> I would like to call irsend (a program that is part of lirc package) from
> >> >> Squeak on the Raspberry Pi.  Can anyone please post some sample code.
> >> >>
> >> >
> >> >I'm not familiar with it myself, but if irsend is just a simple command line
> >> >program then I should think that you could call it easily using OSProcess.
> >> >
> >>
> >> Thanks for the reply.  OSProcess sounds like it is what I need but I can't
> >> find any install instructions, probably because I don't know much about
> >> Squeak and Linux and I'm not sure where to look.
> >>
> >
> >Open a SqueakMap Package Loader:
> >
> >  world -> open... -> SqueakMap Catalog
> >
> >In the SqueakMap Package Loader, select package OSProcess. Expand that
> >category and you will find entries for version 4.4.11 and for "head".
> >Either one is fine, but I usually recommend just using the latest version,
> >so select "head" and install it.
> >
> >Assuming that you want to run irsend with some command line parameters,
> >try inspecting the following expression (but use some command parameters
> >that actually do something):
> >
> >  OSProcess command: 'irsend foo bar baz'
> >
> >The result will be an instance of ExternalUnixOSProcess that is a proxy
> >for the actual irsend program that you just executed. You can send it
> >#succeeded to see if the command was evaluated without error.
> >
> >I think this is sufficient for what you are trying to do, but you can also
> >do fancier things with external programs if you load CommandShell (also
> >on SqueakMap).
> >
> >For additional background see http://wiki.squeak.org/squeak/708 and
> >http://wiki.squeak.org/squeak/1914.
> >
> >Follow up questions welcome :)
> >
> >Dave
> >
> >
> -----------------------------------------------------------
> Louis LaBrunda
> Keystone Software Corp.
> SkypeMe callto://PhotonDemon
> mailto:[hidden email] http://www.Keystone-Software.com
>

Reply | Threaded
Open this post in threaded view
|

How to call irsend

Louis LaBrunda
Hey Dave,

Thanks for the info.  Looking at the code, I see that ExternalUnixOSProcess
is returned from "OSProcess command:...".  It has some nice methods for
checking if the command finished ok.

I added some code to the method that calls irsend to check if the command
is finished and if it was successful, looping on a small delay.  If after
awhile it has not finished successfully I try again for a few times and
then give up.  Since I'm sure the irsend command is fine, the errors should
just be transient of the odd timing nature and retrying should work.

Lou

>There are a couple of ways that a unix program can provide error output.
>The exit status is a simple way to communicate either success, or one of
>possibly several not so successful outcomes. This is useful for programs
>that are used in shell scripts for example. The other way is for the
>program to write error messages to its stderr output stream. This is
>common for programs for which which a user is expected to read the error
>messages.
>
>I don't see anything in the man page for irsend that explains the exit
>status values, so it's a good bet that 0 means goodness and anything
>else means not so good. That might not be enough information to change
>the channel on your TV, but as you say I'd go ahead and try that first
>and see if it is good enough.
>
>If you need to read the error output from the stdout stream (i.e. the
>error messages that would normally go to the console when you run
>the irsend program), you can do this by loading the CommandShell
>package from SqueakMap, then do something like this:
>
>irsend := ProxyPipeline command: 'irsend foo bar baz'.
>
>irsend last processProxy ==> an ExternalUnixOSProcess with pid 4157 on /usr/bin/irsend (complete, normal termination with status 1)
>
>irsend errorUpToEnd ==> 'irsend: could not connect to socket
>irsend: No such file or directory
>'
>
>But I think this is more complexity than you really need for this, so
>definitely you should first try just checking for exit status 0 and see
>if that does what you need.
>
>Dave
>
>
>On Thu, Feb 07, 2013 at 11:37:17AM -0500, Louis LaBrunda wrote:
>> Hi Dave,
>>
>> Last night I left the RasPi running my Squeak code to change the channels.
>> Most worked just fine.  One of the calls to "OSProcess command:..." says it
>> had a "... normal termination with status 1".  It didn't change the
>> channel.  I will look through the code for what this and other status codes
>> mean but can you tell me or point me to some docs.
>>
>> I would like to test for errors and retry.  For now I think I will just
>> test for non zero.
>>
>> Lou
>>
>> On Tue, 5 Feb 2013 17:22:50 -0500, "David T. Lewis" <[hidden email]>
>> wrote:
>>
>> >On Tue, Feb 05, 2013 at 03:55:14PM -0500, Louis LaBrunda wrote:
>> >>
>> >> >On Mon, Feb 04, 2013 at 02:07:12PM -0500, Louis LaBrunda wrote:
>> >> >> Hi Guys,
>> >> >>
>> >> >> I would like to call irsend (a program that is part of lirc package) from
>> >> >> Squeak on the Raspberry Pi.  Can anyone please post some sample code.
>> >> >>
>> >> >
>> >> >I'm not familiar with it myself, but if irsend is just a simple command line
>> >> >program then I should think that you could call it easily using OSProcess.
>> >> >
>> >>
>> >> Thanks for the reply.  OSProcess sounds like it is what I need but I can't
>> >> find any install instructions, probably because I don't know much about
>> >> Squeak and Linux and I'm not sure where to look.
>> >>
>> >
>> >Open a SqueakMap Package Loader:
>> >
>> >  world -> open... -> SqueakMap Catalog
>> >
>> >In the SqueakMap Package Loader, select package OSProcess. Expand that
>> >category and you will find entries for version 4.4.11 and for "head".
>> >Either one is fine, but I usually recommend just using the latest version,
>> >so select "head" and install it.
>> >
>> >Assuming that you want to run irsend with some command line parameters,
>> >try inspecting the following expression (but use some command parameters
>> >that actually do something):
>> >
>> >  OSProcess command: 'irsend foo bar baz'
>> >
>> >The result will be an instance of ExternalUnixOSProcess that is a proxy
>> >for the actual irsend program that you just executed. You can send it
>> >#succeeded to see if the command was evaluated without error.
>> >
>> >I think this is sufficient for what you are trying to do, but you can also
>> >do fancier things with external programs if you load CommandShell (also
>> >on SqueakMap).
>> >
>> >For additional background see http://wiki.squeak.org/squeak/708 and
>> >http://wiki.squeak.org/squeak/1914.
>> >
>> >Follow up questions welcome :)
>> >
>> >Dave
>> >
>> >
>> -----------------------------------------------------------
>> Louis LaBrunda
>> Keystone Software Corp.
>> SkypeMe callto://PhotonDemon
>> mailto:[hidden email] http://www.Keystone-Software.com
>>
>
-----------------------------------------------------------
Louis LaBrunda
Keystone Software Corp.
SkypeMe callto://PhotonDemon
mailto:[hidden email] http://www.Keystone-Software.com


Reply | Threaded
Open this post in threaded view
|

Re: How to call irsend

David T. Lewis
That sound right to me. The exit status of the program is set some time
after it exits (by means of a unix signal triggering a Smalltalk semaphore
which wakes up a process that updates the status in the ExternalUnixOSProcess).

For a simple command line program like this, just waiting a couple hundred
milliseconds after you evaluate the command will allow time for the program
to run and for Squeak to be informed of the outcome. So a retry loop with
200ms delay is probably fine in this case. Come to think of it, there's
an OSProcess class>>waitForCommand: that will probably do exactly what you
want in this case.

Dave


On Fri, Feb 08, 2013 at 10:17:29AM -0500, Louis LaBrunda wrote:

> Hey Dave,
>
> Thanks for the info.  Looking at the code, I see that ExternalUnixOSProcess
> is returned from "OSProcess command:...".  It has some nice methods for
> checking if the command finished ok.
>
> I added some code to the method that calls irsend to check if the command
> is finished and if it was successful, looping on a small delay.  If after
> awhile it has not finished successfully I try again for a few times and
> then give up.  Since I'm sure the irsend command is fine, the errors should
> just be transient of the odd timing nature and retrying should work.
>
> Lou
>
> >There are a couple of ways that a unix program can provide error output.
> >The exit status is a simple way to communicate either success, or one of
> >possibly several not so successful outcomes. This is useful for programs
> >that are used in shell scripts for example. The other way is for the
> >program to write error messages to its stderr output stream. This is
> >common for programs for which which a user is expected to read the error
> >messages.
> >
> >I don't see anything in the man page for irsend that explains the exit
> >status values, so it's a good bet that 0 means goodness and anything
> >else means not so good. That might not be enough information to change
> >the channel on your TV, but as you say I'd go ahead and try that first
> >and see if it is good enough.
> >
> >If you need to read the error output from the stdout stream (i.e. the
> >error messages that would normally go to the console when you run
> >the irsend program), you can do this by loading the CommandShell
> >package from SqueakMap, then do something like this:
> >
> >irsend := ProxyPipeline command: 'irsend foo bar baz'.
> >
> >irsend last processProxy ==> an ExternalUnixOSProcess with pid 4157 on /usr/bin/irsend (complete, normal termination with status 1)
> >
> >irsend errorUpToEnd ==> 'irsend: could not connect to socket
> >irsend: No such file or directory
> >'
> >
> >But I think this is more complexity than you really need for this, so
> >definitely you should first try just checking for exit status 0 and see
> >if that does what you need.
> >
> >Dave
> >
> >
> >On Thu, Feb 07, 2013 at 11:37:17AM -0500, Louis LaBrunda wrote:
> >> Hi Dave,
> >>
> >> Last night I left the RasPi running my Squeak code to change the channels.
> >> Most worked just fine.  One of the calls to "OSProcess command:..." says it
> >> had a "... normal termination with status 1".  It didn't change the
> >> channel.  I will look through the code for what this and other status codes
> >> mean but can you tell me or point me to some docs.
> >>
> >> I would like to test for errors and retry.  For now I think I will just
> >> test for non zero.
> >>
> >> Lou
> >>
> >> On Tue, 5 Feb 2013 17:22:50 -0500, "David T. Lewis" <[hidden email]>
> >> wrote:
> >>
> >> >On Tue, Feb 05, 2013 at 03:55:14PM -0500, Louis LaBrunda wrote:
> >> >>
> >> >> >On Mon, Feb 04, 2013 at 02:07:12PM -0500, Louis LaBrunda wrote:
> >> >> >> Hi Guys,
> >> >> >>
> >> >> >> I would like to call irsend (a program that is part of lirc package) from
> >> >> >> Squeak on the Raspberry Pi.  Can anyone please post some sample code.
> >> >> >>
> >> >> >
> >> >> >I'm not familiar with it myself, but if irsend is just a simple command line
> >> >> >program then I should think that you could call it easily using OSProcess.
> >> >> >
> >> >>
> >> >> Thanks for the reply.  OSProcess sounds like it is what I need but I can't
> >> >> find any install instructions, probably because I don't know much about
> >> >> Squeak and Linux and I'm not sure where to look.
> >> >>
> >> >
> >> >Open a SqueakMap Package Loader:
> >> >
> >> >  world -> open... -> SqueakMap Catalog
> >> >
> >> >In the SqueakMap Package Loader, select package OSProcess. Expand that
> >> >category and you will find entries for version 4.4.11 and for "head".
> >> >Either one is fine, but I usually recommend just using the latest version,
> >> >so select "head" and install it.
> >> >
> >> >Assuming that you want to run irsend with some command line parameters,
> >> >try inspecting the following expression (but use some command parameters
> >> >that actually do something):
> >> >
> >> >  OSProcess command: 'irsend foo bar baz'
> >> >
> >> >The result will be an instance of ExternalUnixOSProcess that is a proxy
> >> >for the actual irsend program that you just executed. You can send it
> >> >#succeeded to see if the command was evaluated without error.
> >> >
> >> >I think this is sufficient for what you are trying to do, but you can also
> >> >do fancier things with external programs if you load CommandShell (also
> >> >on SqueakMap).
> >> >
> >> >For additional background see http://wiki.squeak.org/squeak/708 and
> >> >http://wiki.squeak.org/squeak/1914.
> >> >
> >> >Follow up questions welcome :)
> >> >
> >> >Dave
> >> >
> >> >
> >> -----------------------------------------------------------
> >> Louis LaBrunda
> >> Keystone Software Corp.
> >> SkypeMe callto://PhotonDemon
> >> mailto:[hidden email] http://www.Keystone-Software.com
> >>
> >
> -----------------------------------------------------------
> Louis LaBrunda
> Keystone Software Corp.
> SkypeMe callto://PhotonDemon
> mailto:[hidden email] http://www.Keystone-Software.com
>

Reply | Threaded
Open this post in threaded view
|

How to call irsend

Louis LaBrunda
Hi Dave,

OSProcess class>>waitForCommand: (and what it calls) looks good but what if
runState never gets to #complete?  Would it loop forever or can't that
happen.  For now, I wait a second and after 50 tries give up and try the
command again.  I retry the command 50 times and then give up and
reschedule the request for the next time.

If I could be sure of completion (or if you added a completion limit, not
that I'm asking) it would simplify my code.

Lou

>That sound right to me. The exit status of the program is set some time
>after it exits (by means of a unix signal triggering a Smalltalk semaphore
>which wakes up a process that updates the status in the ExternalUnixOSProcess).

>For a simple command line program like this, just waiting a couple hundred
>milliseconds after you evaluate the command will allow time for the program
>to run and for Squeak to be informed of the outcome. So a retry loop with
>200ms delay is probably fine in this case. Come to think of it, there's
>an OSProcess class>>waitForCommand: that will probably do exactly what you
>want in this case.
-----------------------------------------------------------
Louis LaBrunda
Keystone Software Corp.
SkypeMe callto://PhotonDemon
mailto:[hidden email] http://www.Keystone-Software.com


Reply | Threaded
Open this post in threaded view
|

Re: How to call irsend

David T. Lewis
On Fri, Feb 08, 2013 at 12:00:06PM -0500, Louis LaBrunda wrote:
> Hi Dave,
>
> OSProcess class>>waitForCommand: (and what it calls) looks good but what if
> runState never gets to #complete?  Would it loop forever or can't that
> happen.  For now, I wait a second and after 50 tries give up and try the
> command again.  I retry the command 50 times and then give up and
> reschedule the request for the next time.

I wouldn't say that it can't happen, but the completion notification is
fairly reliable and I doubt there is any way for your irsend command to
not exit. Since you are just running a simple command, I don't think you
have anything to worry about, it should just work.

Dave

>
> If I could be sure of completion (or if you added a completion limit, not
> that I'm asking) it would simplify my code.
>
> Lou
>
> >That sound right to me. The exit status of the program is set some time
> >after it exits (by means of a unix signal triggering a Smalltalk semaphore
> >which wakes up a process that updates the status in the ExternalUnixOSProcess).
>
> >For a simple command line program like this, just waiting a couple hundred
> >milliseconds after you evaluate the command will allow time for the program
> >to run and for Squeak to be informed of the outcome. So a retry loop with
> >200ms delay is probably fine in this case. Come to think of it, there's
> >an OSProcess class>>waitForCommand: that will probably do exactly what you
> >want in this case.
> -----------------------------------------------------------
> Louis LaBrunda
> Keystone Software Corp.
> SkypeMe callto://PhotonDemon
> mailto:[hidden email] http://www.Keystone-Software.com
>

Reply | Threaded
Open this post in threaded view
|

How to call irsend

Louis LaBrunda
Hi Dave,

I have written two classes to manage a bunch of irsend command calls (to
change the cable box channel) at a given time and reschedule it for another
day.  I have two questions.

1) Where would be a good place in Squeak to document how each class works?
The classes are fairly simple.  One class holds the information for what
command should be run and when.  The other class manages a group of similar
(by programmer choice) commands and run then at the proper time.  How they
work together requires some documenting.

2) It seems to me the two classes I have written would fit nicely into your
OSProcess... group of classes.  I would like to make these classes
available under the MIT licence and I hoping you will accept them into the
fold and distribute them with your package.  I'm not familiar enough with
Squeak to even know where to start to distribute them on my own.

Lou
-----------------------------------------------------------
Louis LaBrunda
Keystone Software Corp.
SkypeMe callto://PhotonDemon
mailto:[hidden email] http://www.Keystone-Software.com


Reply | Threaded
Open this post in threaded view
|

Re: How to call irsend

Bert Freudenberg

On 2013-02-18, at 18:09, Louis LaBrunda <[hidden email]> wrote:

> Hi Dave,
>
> I have written two classes to manage a bunch of irsend command calls (to
> change the cable box channel) at a given time and reschedule it for another
> day.  I have two questions.
>
> 1) Where would be a good place in Squeak to document how each class works?
> The classes are fairly simple.  One class holds the information for what
> command should be run and when.  The other class manages a group of similar
> (by programmer choice) commands and run then at the proper time.  How they
> work together requires some documenting.

The class comment.

> 2) It seems to me the two classes I have written would fit nicely into your
> OSProcess... group of classes.  I would like to make these classes
> available under the MIT licence and I hoping you will accept them into the
> fold and distribute them with your package.  I'm not familiar enough with
> Squeak to even know where to start to distribute them on my own.


Certainly calling out to a special-purpose tool does not belong in the generic OSProcess package.

Besides, why did you make it so complicated in the first place? Why not connect to LIRC's TCP socket directly? irsend is a trivial little program that does nothing more than forward its command line arguments to the LIRC demon. Then you wouldn't even need OSProcess. The protocol is straight-forward:

http://www.lirc.org/html/technical.html#applications

- Bert -


Reply | Threaded
Open this post in threaded view
|

Re: Re: How to call irsend

Louis LaBrunda
Hi Bert,

Thanks for the reply.

>On 2013-02-18, at 18:09, Louis LaBrunda <[hidden email]> wrote:
>
>> Hi Dave,
>>
>> I have written two classes to manage a bunch of irsend command calls (to
>> change the cable box channel) at a given time and reschedule it for another
>> day.  I have two questions.
>>
>> 1) Where would be a good place in Squeak to document how each class works?
>> The classes are fairly simple.  One class holds the information for what
>> command should be run and when.  The other class manages a group of similar
>> (by programmer choice) commands and run then at the proper time.  How they
>> work together requires some documenting.
>
>The class comment.

I thought about the class comment but it looks like it takes only one line.
Unless I'm looking in the wrong place or at it wrong?

>> 2) It seems to me the two classes I have written would fit nicely into your
>> OSProcess... group of classes.  I would like to make these classes
>> available under the MIT licence and I hoping you will accept them into the
>> fold and distribute them with your package.  I'm not familiar enough with
>> Squeak to even know where to start to distribute them on my own.

>Certainly calling out to a special-purpose tool does not belong in the generic OSProcess package.

It is not a special-purpose tool.  There is no mention of LIRC or irsend in
either class.  The classes run and schedule any command that Dave's
OSProcess>command: can handle.  It does things like run the command every
Tuesday at 20:00 hours.

>Besides, why did you make it so complicated in the first place? Why not connect to LIRC's TCP socket directly? irsend is a trivial little program that does nothing more than forward its command line arguments to the LIRC demon. Then you wouldn't even need OSProcess. The protocol is straight-forward:
>
>http://www.lirc.org/html/technical.html#applications

I will take a look at it.  I don't really know much about LIRC and got on
the to WinLIRC>transmit.exe and LIRC>irsend early on and never got much
more involved in how LIRC works.  It would be nice to do more than irsend
does so controlling LIRC via a socket could be nice.  I would still need
the scheduling code but then it would be special purpose to LIRC.  But
still something to look into.

Lou
-----------------------------------------------------------
Louis LaBrunda
Keystone Software Corp.
SkypeMe callto://PhotonDemon
mailto:[hidden email] http://www.Keystone-Software.com


Reply | Threaded
Open this post in threaded view
|

Re: Re: How to call irsend

Bert Freudenberg

On 2013-02-18, at 19:28, Louis LaBrunda <[hidden email]> wrote:

> Hi Bert,
>
> Thanks for the reply.
>
>> On 2013-02-18, at 18:09, Louis LaBrunda <[hidden email]> wrote:
>>
>>> Hi Dave,
>>>
>>> I have written two classes to manage a bunch of irsend command calls (to
>>> change the cable box channel) at a given time and reschedule it for another
>>> day.  I have two questions.
>>>
>>> 1) Where would be a good place in Squeak to document how each class works?
>>> The classes are fairly simple.  One class holds the information for what
>>> command should be run and when.  The other class manages a group of similar
>>> (by programmer choice) commands and run then at the proper time.  How they
>>> work together requires some documenting.
>>
>> The class comment.
>
> I thought about the class comment but it looks like it takes only one line.
> Unless I'm looking in the wrong place or at it wrong?

Click the the question mark button between instance and class in the system browser.

The one line is just an annotation for convenience.

>>> 2) It seems to me the two classes I have written would fit nicely into your
>>> OSProcess... group of classes.  I would like to make these classes
>>> available under the MIT licence and I hoping you will accept them into the
>>> fold and distribute them with your package.  I'm not familiar enough with
>>> Squeak to even know where to start to distribute them on my own.
>
>> Certainly calling out to a special-purpose tool does not belong in the generic OSProcess package.
>
> It is not a special-purpose tool.  There is no mention of LIRC or irsend in
> either class.  The classes run and schedule any command that Dave's
> OSProcess>command: can handle.  It does things like run the command every
> Tuesday at 20:00 hours.

It's up to Dave then. Still seems rather special-purpose to me ;)

- Bert -

>> Besides, why did you make it so complicated in the first place? Why not connect to LIRC's TCP socket directly? irsend is a trivial little program that does nothing more than forward its command line arguments to the LIRC demon. Then you wouldn't even need OSProcess. The protocol is straight-forward:
>>
>> http://www.lirc.org/html/technical.html#applications
>
> I will take a look at it.  I don't really know much about LIRC and got on
> the to WinLIRC>transmit.exe and LIRC>irsend early on and never got much
> more involved in how LIRC works.  It would be nice to do more than irsend
> does so controlling LIRC via a socket could be nice.  I would still need
> the scheduling code but then it would be special purpose to LIRC.  But
> still something to look into.
>
> Lou
> -----------------------------------------------------------
> Louis LaBrunda
> Keystone Software Corp.
> SkypeMe callto://PhotonDemon
> mailto:[hidden email] http://www.Keystone-Software.com
>
>




Reply | Threaded
Open this post in threaded view
|

Re: Re: How to call irsend

David T. Lewis
On Mon, Feb 18, 2013 at 07:32:29PM +0100, Bert Freudenberg wrote:

>
> On 2013-02-18, at 19:28, Louis LaBrunda <[hidden email]> wrote:
>
> > Hi Bert,
> >
> > Thanks for the reply.
> >
> >> On 2013-02-18, at 18:09, Louis LaBrunda <[hidden email]> wrote:
> >>
> >>> Hi Dave,
> >>>
> >>> I have written two classes to manage a bunch of irsend command calls (to
> >>> change the cable box channel) at a given time and reschedule it for another
> >>> day.  I have two questions.
> >>>
> >>> 1) Where would be a good place in Squeak to document how each class works?
> >>> The classes are fairly simple.  One class holds the information for what
> >>> command should be run and when.  The other class manages a group of similar
> >>> (by programmer choice) commands and run then at the proper time.  How they
> >>> work together requires some documenting.
> >>
> >> The class comment.
> >
> > I thought about the class comment but it looks like it takes only one line.
> > Unless I'm looking in the wrong place or at it wrong?
>
> Click the the question mark button between instance and class in the system browser.
>
> The one line is just an annotation for convenience.
>
> >>> 2) It seems to me the two classes I have written would fit nicely into your
> >>> OSProcess... group of classes.  I would like to make these classes
> >>> available under the MIT licence and I hoping you will accept them into the
> >>> fold and distribute them with your package.  I'm not familiar enough with
> >>> Squeak to even know where to start to distribute them on my own.
> >
> >> Certainly calling out to a special-purpose tool does not belong in the generic OSProcess package.
> >
> > It is not a special-purpose tool.  There is no mention of LIRC or irsend in
> > either class.  The classes run and schedule any command that Dave's
> > OSProcess>command: can handle.  It does things like run the command every
> > Tuesday at 20:00 hours.
>
> It's up to Dave then. Still seems rather special-purpose to me ;)

Well sure, by all means, please send a copy :) If it's not too big you can
just post it to the list here.

If it looks like a good fit, we can put it in OSProcess. There is also nothing
wrong with you just making a small project on SqueakSource (or whatever is
replacing it, I'm not sure I've figured that out). You could just say your
project depends on OSProcess, and that would be fine too. That way you could
enter it on SqueakMap (the package catalog) so that someone looking for irsend
could spot it more easily.

Dave


Reply | Threaded
Open this post in threaded view
|

Re: Re: Re: Re: How to call irsend

Louis LaBrunda
On Mon, 18 Feb 2013 15:16:21 -0500, "David T. Lewis" <[hidden email]>
wrote:

>On Mon, Feb 18, 2013 at 07:32:29PM +0100, Bert Freudenberg wrote:
>>
>> On 2013-02-18, at 19:28, Louis LaBrunda <[hidden email]> wrote:
>>
>> > Hi Bert,
>> >
>> > Thanks for the reply.
>> >
>> >> On 2013-02-18, at 18:09, Louis LaBrunda <[hidden email]> wrote:
>> >>
>> >>> Hi Dave,
>> >>>
>> >>> I have written two classes to manage a bunch of irsend command calls (to
>> >>> change the cable box channel) at a given time and reschedule it for another
>> >>> day.  I have two questions.
>> >>>
>> >>> 1) Where would be a good place in Squeak to document how each class works?
>> >>> The classes are fairly simple.  One class holds the information for what
>> >>> command should be run and when.  The other class manages a group of similar
>> >>> (by programmer choice) commands and run then at the proper time.  How they
>> >>> work together requires some documenting.
>> >>
>> >> The class comment.
>> >
>> > I thought about the class comment but it looks like it takes only one line.
>> > Unless I'm looking in the wrong place or at it wrong?
>>
>> Click the the question mark button between instance and class in the system browser.
>>
>> The one line is just an annotation for convenience.
>>
>> >>> 2) It seems to me the two classes I have written would fit nicely into your
>> >>> OSProcess... group of classes.  I would like to make these classes
>> >>> available under the MIT licence and I hoping you will accept them into the
>> >>> fold and distribute them with your package.  I'm not familiar enough with
>> >>> Squeak to even know where to start to distribute them on my own.
>> >
>> >> Certainly calling out to a special-purpose tool does not belong in the generic OSProcess package.
>> >
>> > It is not a special-purpose tool.  There is no mention of LIRC or irsend in
>> > either class.  The classes run and schedule any command that Dave's
>> > OSProcess>command: can handle.  It does things like run the command every
>> > Tuesday at 20:00 hours.
>>
>> It's up to Dave then. Still seems rather special-purpose to me ;)
>
>Well sure, by all means, please send a copy :) If it's not too big you can
>just post it to the list here.

>If it looks like a good fit, we can put it in OSProcess. There is also nothing
>wrong with you just making a small project on SqueakSource (or whatever is
>replacing it, I'm not sure I've figured that out). You could just say your
>project depends on OSProcess, and that would be fine too. That way you could
>enter it on SqueakMap (the package catalog) so that someone looking for irsend
>could spot it more easily.
>Dave

Now that Bert has clued me in on how to use the class comment for some
documentation, I will spend some time doing that.  I have some less fun
stuff to deal with, so it may take me a little while.

Again, the two classes are really about scheduling calls to
OSProcess>command: and not the command being called.  I just needed them to
call irsend.  Anyway, I will post the code when I can (after I write some
class comments) and you can decide if it is a good fit.  Thanks for all the
help.

Lou
-----------------------------------------------------------
Louis LaBrunda
Keystone Software Corp.
SkypeMe callto://PhotonDemon
mailto:[hidden email] http://www.Keystone-Software.com


Reply | Threaded
Open this post in threaded view
|

How to call irsend

Louis LaBrunda
In reply to this post by David T. Lewis
Hey Dave,

I'm close to being ready to give you my code but first one last question
(hopefully).  There are two classes:

ScheduledOSCall -- Instances of this class hold the command to be run and
the time and frequency to run it.

ScheduledOSCalls -- Instances of this class hold groups of instances of
ScheduledOSCall.

I'm not pleased with these names, especially ScheduledOSCalls because it's
name only vaguely refers to its function.  I would love a better name for
ScheduledOSCalls and I'm open to a better name for ScheduledOSCall.  Please
give it some thought and help me out with better names.

Lou
-----------------------------------------------------------
Louis LaBrunda
Keystone Software Corp.
SkypeMe callto://PhotonDemon
mailto:[hidden email] http://www.Keystone-Software.com


12