Discussion:
[hercules-390] Access to host hardware
broweo@yahoo.com [hercules-390]
2018-04-07 20:48:30 UTC
Permalink
Is there a mechanism for a program running in the emulator to access host hardware e.g. gpio pins on a raspberry pi?
kerravon86@yahoo.com.au [hercules-390]
2018-04-07 21:12:46 UTC
Permalink
Post by ***@yahoo.com [hercules-390]
Is there a mechanism for a program running in
the emulator to access host hardware e.g. gpio
pins on a raspberry pi?
I don't think so, but you could probably write
a DIAG to do that, or modify Hercules to
intercept an SVC call. Currently I am
intercepting SVC 120 in order to access
the host's tcp/ip stack. Note that Jason
Winter created a special instruction to be
intercepted, but I think it is cleaner to
overload SVC 120, which I am also using
for other APIs.

BFN. Paul.
ivan@vmfacility.fr [hercules-390]
2018-04-07 21:44:16 UTC
Permalink
Actually you *COULD* (but it does indeed requires modification to hercules).

You could use the RDD/WRD instructions (Read Direct/Write Direct) which were (apparently) intended for early cross processor communication.


Hercules doesn't support these, but you could write a module that would support it to some extent !
broweo@yahoo.com [hercules-390]
2018-04-07 22:32:29 UTC
Permalink
could i see your code?
kerravon86@yahoo.com.au [hercules-390]
2018-04-07 22:43:40 UTC
Permalink
Post by ***@yahoo.com [hercules-390]
could i see your code?
You didn't quote the old message so I don't know
if you are talking to me or Ivan.

Assuming it is me, then the TCP/IP code is in a
beta version of Hercules/380 in the files area here:

https://groups.yahoo.com/neo/groups/hercules-os380/info

and I have reproduced the relevant bit here:

general2.c:

/*-------------------------------------------------------------------*/
/* 0A SVC - Supervisor Call [RR] */
/*-------------------------------------------------------------------*/
DEF_INST(supervisor_call)
{
BYTE i; /* Instruction byte 1 */
PSA *psa; /* -> prefixed storage area */
RADR px; /* prefix */
int rc; /* Return code */

RR_SVC(inst, regs, i);

#if 1
/* if we have an SVC and R2 is set to a magic number, then
this is actually a request from EZASOKET. */
if ((i == 120) && (regs->GR_L(0) == 0xffffffe1)
&& (regs->GR_L(1) == 0xffffffe1)
)
{
regs->GR_L(1) = regs->GR_L(2); /* normal parameter list */
ezahandler(regs);
return;
}
#endif


I just noticed the comment is wrong though.
It's if R0 and R1 are set to magic numbers,
not R2.

BFN. Paul.
Martin Truebner Martin@pi-sysprog.de [hercules-390]
2018-04-08 09:02:29 UTC
Permalink
I make the light change from a herc guest using DIAG
see here:



control of the read and green light is done from within the guest.

Here are the ingredients:

Make DIAG 8 in the guest usable (in DOS/VS and up it is just to
remove some restrictions in the SUPVR to allow the CPCOM-SVC (=DIAG8)
for common users- hercules looks for the op-sys like VM) -- for MVS
this is certainly a different method (but the code is the same: a DIAG
8 from privileged code with regs having area and length to pass to
hosting system).

Have some task issue a command (I do "sh ./Z/REDBLINK && "

on the hosting system make available whatever you invoke - here is
REDBLINK
#!/bin/bash
echo 0 >/sys/class/gpio/gpio17/value
while :
do
echo 1 >/sys/class/gpio/gpio27/value
sleep 0.7
echo 0 >/sys/class/gpio/gpio27/value
sleep 0.7
done
broweo@yahoo.com [hercules-390]
2018-04-08 13:53:28 UTC
Permalink
@martin: Thanks - diag8 seems like an easy way to start with for something like blinking an LED.
broweo@yahoo.com [hercules-390]
2018-04-08 13:38:27 UTC
Permalink
@kerravon86:
That's exactly the kind of thing i was thinking of - thanks.
broweo@yahoo.com [hercules-390]
2018-04-07 22:33:23 UTC
Permalink
also, thanks ;-)
dwegscheid@sbcglobal.net [hercules-390]
2018-04-08 13:55:21 UTC
Permalink
This post might be inappropriate. Click to display it.
Joe Monk joemonk64@gmail.com [hercules-390]
2018-04-08 14:16:24 UTC
Permalink
I dont understand the issue here, why are we talking DIAGs, etc when there
is a much simpler way?

Access to host hardware is simple ... just use the MVS reader and printer
as I/O devices on specific TCPIP ports in the Hercules.cnf file. Then have
a daemon running on the raspberry pi which listens on those port for input
from the Hercules printer or outputs to the Hercules reader.

You can then write a protocol with commands such as STATUS, BLINK, etc. in
order to get the PI GPIO to do what you want.

Joe
Post by ***@sbcglobal.net [hercules-390]
I didn't add it to hercules, but I wrote a python daemon that would
connect to a network port, read data, and manipulate some lights. I change
the config for one of the unused printers (don't remember if it was a 3211
or 1403) to be configured for the that port. allocated the printer directly
in the JCL (instead of SYSOUT=A), and just wrote to the printer when I
wanted the lights to change. All done on MVS 3.8j (probably on tk3upd,
possible tk4-, I just remember I had a pile of 1403s and 3211s to use)
It's a hack, but pretty quick. I was actually able to get MVS 3.8j talking
to Home Assistant using the same technique. It's silly, but I was bored.
Martin Truebner Martin@pi-sysprog.de [hercules-390]
2018-04-09 08:40:44 UTC
Permalink
This post might be inappropriate. Click to display it.
Kevin Monceaux Kevin@RawFedDogs.net [hercules-390]
2018-04-09 13:23:31 UTC
Permalink
Would be even better if the punch could be attached to a TCP/IP socket.
I've had to catch and filter printer output before and it wasn't pretty,
particularly since there wasn't a trivial EOF (^Z or whatever) at the end
of the data stream.
I did something similar in the past. It wasn't too bad, on Linux at least.
I created a named pipe, pointed the printer in the Hercules config file to
it, and used a Perl script to read from it and send the output to enscript.
The Perl script amounted to about 25 lines of code. Most of that was
checking for and counting the END JOB/TSU/STC lines on the JES2 separator
pages to determine when the EOF was reached. Some type of EOF indicator
would definitely be helpful.
--
Kevin
http://www.RawFedDogs.net
http://www.Lassie.xyz
http://www.WacoAgilityGroup.org
Bruceville, TX

What's the definition of a legacy system? One that works!
Errare humanum est, ignoscere caninum.
'Bill Turner, WB4ALM' wb4alm@arrl.net [hercules-390]
2018-04-09 14:51:19 UTC
Permalink
On Mon, Apr 09, 2018 at 08:31:39AM +0000, Mark Morgan Lloyd
Would be even better if the punch could be attached to a TCP/IP socket.
I've had to catch and filter printer output before and it wasn't pretty,
particularly since there wasn't a trivial EOF (^Z or whatever) at
the end
of the data stream.
I did something similar in the past. It wasn't too bad, on Linux at least.
I created a named pipe, pointed the printer in the Hercules config file to
it, and used a Perl script to read from it and send the output to enscript.
The Perl script amounted to about 25 lines of code. Most of that was
checking for and counting the END JOB/TSU/STC lines on the JES2 separator
pages to determine when the EOF was reached. *Some type of EOF indicator**
**would definitely be helpful. *
*Consider using the Separator exit to generate or act as an "EOF"
/s/ Bill Turner, wb4alm
*
--
Kevin
http://www.RawFedDogs.net
http://www.Lassie.xyz
http://www.WacoAgilityGroup.org
Bruceville, TX
What's the definition of a legacy system? One that works!
Errare humanum est, ignoscere caninum.
------------------------------------------------------------------------
------------------------------------------------------------------------
broweo@yahoo.com [hercules-390]
2018-04-12 14:41:07 UTC
Permalink
@kevin I've been doing a primitive version of this by tail'ing the printer file into more based on the number of lines shown for the job in the log.

I'm no linux guru but i think i could write a python program to read the pipe and split the output into separate files by job with the jobname/number in the filename.


I can maybe start by splitting the existing file and graduate to a pipe.
Andrew Gadsby andrew@gadsby.me.uk [hercules-390]
2018-04-14 14:06:25 UTC
Permalink
@kevin. I have a Perl script for splitting print jobs as well as a web presentation front end. I’m travelling at the moment but will send the link when I get back.

Btw you cannot use pipes as these buffer the output so you need to use the socket interface to make it work.

Andy

Loading...