[Search for users] [Overall Top Noters] [List of all Conferences] [Download this site]

Conference 7.286::atarist

Title:Atari ST, TT, & Falcon
Notice:Please read note 1.0 and its replies before posting!
Moderator:FUNYET::ANDERSON
Created:Mon Apr 04 1988
Last Modified:Tue May 06 1997
Last Successful Update:Fri Jun 06 1997
Number of topics:1433
Total number of notes:10312

22.0. "Appl. communcation (GEM messages)" by AKOV11::KING (George Orwell was an Optimist!) Thu Apr 07 1988 10:37

    I was reading an article that talks about a pipe(line?) that allows
    the 6 desk accessories and a program to communicate with each other,
    but to do so requires that you know the process tag of the process
    you wish to send a message to.  The article lists a C function that
    is included in the ST developers kit, but it is not included in
    my (Lattice) C.  I also could not locate the function in my GEM
    manual (Abbacus), or the AES documentation.  Does anyone know anything
    about this? is it in the roms or was it a software routine included
    with the developers C?  Does MWC have a similar function?  Where
    in ram is the reference table of process tags stored?
    
    Any help would be *greatly* appreciated!

    Bob K.
T.RTitleUserPersonal
Name
DateLines
22.1appl_read, appl_writePRNSYS::LOMICKAJJeff LomickaThu Apr 07 1988 14:2022
According to the Mark Williams documentation, I expect that you are
referring to the routines appl_write() and appl_read().  These are AES
routines, and are called as follows:

	appl_write( handle, length, buffer)
	int handle;	/* Application handle to receive message */
	int length;	/* Length of message in bytes */
	char *buffer; 	/* message to send */

	appl_read( handle, length, buffer)
	int handle;	/* Handle of app. that owns the pipe to be read (?) */
	int length;	/* Number of bytes to read */
	char *buffer;	/* Place to put the data */

Both routines return 0 on error.  There is some possibility that these
routines will interact with the "message" event type of evnt_multi().

I have never tried these routines, and the documentation isn't all that
clear.  Please let us know if they do anything useful for you, and if
so, how.


22.2works fine...SUOSW2::KAISERHoly St. Asap !Thu Apr 07 1988 16:2610
Your're right, these routines work. I played around with them about a year
ago. I've been able to send a message from an accessory to a GEM program
and vice versa. As I did not have any use for the trick I did not look
at the source since then. May be I even don't have it any more. I will try
to find it at home, if you want me to. Another way I tried was to use something
called scratchpad, if I remember well. I think this way it was much easier
to exchange messages. Anyway, I will have a look when I'm at home.

-Hans

22.3Sorry: I did it in PASCALSUOSW2::KAISERHoly St. Asap !Thu Apr 07 1988 16:280
22.4shel_get and shel_putBOLT::MINOWJe suis marxiste, tendance GrouchoFri Apr 08 1988 00:5473
There's also a (badly documented) pair of routines that, as far as
I can tell, read and write the in-memory representation of DESKTOP.INF.
They're called shel_get and shel_put.  I use them in my terminal emulator
to get the Baud rate.  I learned how to call them by decompiling the VT52
desk accessory.  Don't assume the following is correct.

Martin.

-----
char		shel_buffer[128];
#define END_SHEL_BUFFER	(shel_buffer + sizeof shel_buffer)

/*
 * These routines were invented by dumping EMULATOR.ACC.  Of course,
 * the information is undocumented anywhere.  shel_get() reads
 * a 128 byte buffer consisting of a series of lines of the
 * format
 *   #a stuff \r\n
 *   #b stuff \r\n
 *   #c stuff \r\n
 *   #d       \r\n
 * The text is taken from the desktop.inf file in the root directory.
 * It appears that you can update this buffer by calling shel_put().
 * The #a line is for the terminal -- the first five bytes are  used:
 *   -- the "ctrl" byte
 *   -- the next four bytes are the arguments to Rsconf() -- munged
 *	for conformance to the new desktop.
 * shel_put() updates this buffer (I hope).
 */

get_current_rs232_parameters()
{
	register char		*tp;
	register int		i;
	static char		mung_rs232[] = {
	/*  0  1  2  3  4  5  6  7  8  9 10 11 12 13 14 15	*/
	    1, 2, 7, 9, 0, 3, 4, 5, 6, 8,10,11,12,13,14,15
	};

	shel_get(shel_buffer, sizeof shel_buffer);
	for (tp = shel_buffer; tp < END_SHEL_BUFFER; tp++) {
	    if (*tp++ == '#'
	     && *tp++ == 'a') {
		for (i = 0; i < 5; i++)
		    rs232_info[i] = *tp++ - '0';
		rs232_info[1] = mung_rs232[rs232_info[1]];
		break;
	    }
	}
}

save_current_rs232_parameters()
{
	register char		*tp;
	static char		unmung_rs232[] = {
	/*  0   1   2   3   4   5   6   7   8   9  10  11  12  13  14  15 */
	   '4','0','1','5','6','7','8','2','9','3',':',';','<','=','>','?'
	};

	shel_get(shel_buffer, sizeof shel_buffer);
	for (tp = shel_buffer; tp < END_SHEL_BUFFER; tp++) {
	    if (*tp++ == '#'
	     && *tp++ == 'a') {
		*tp++ = rs232_info[0] + '0';
		*tp++ = unmung_rs232[rs232_info[1]];
		*tp++ = rs232_info[2] + '0';
		*tp++ = rs232_info[3] + '0';
		*tp++ = rs232_info[4] + '0';
		shel_put(shel_buffer, sizeof shel_buffer);
		break;
	    }
	}
}
22.5Thanx, but. . .AKOV11::KINGGeorge Orwell was an Optimist!Fri Apr 08 1988 05:598
    I was asking about MWC to get an indication of whether (sp?) or
    not I should buy the package, I don't currently own it.  I would
    *love* to see the pascal code, was it OSS pascal?  anyone know if
    these routines can be called in assembler, and if so, where are
    they?!?
    
    Thanx for all the info so far.
    Bob K.
22.6Pascal examplesSUOSW2::KAISERHoly St. Asap !Fri Apr 08 1988 06:26202
Here is my Pascal example of appl_read and appl_write, but I'm a bit confused
now.
I tried to start my old .PRG with the .ACC loaded, but after a few seconds it
hung. I don't know the reason, may be it's because the files were compiled
under a former version of my Pascal and on my old 520 ST+ (now I have a 
MEGA ST2). I didn't have the time to compile it again, but I will try 
some time later.
I hope the examples are useful to anyone.

-Hans



File APP.INC
------------

procedure aes_call(op	: integer:
		   var int_in : int_in_parms;
		   var int_out : int_out_parms;
		   var addr_in : addr_in_parms;
		   var addr_out : addr_out_parms); external;

procedure vdi_call(cmd, sub_cmd	: integer;
		   nints, pints : integer;
		   var ctrl : ctrl_parms;
		   var int_in : int_in_parms;
		   var int_out : int_out_parms;
		   var pts_in : pts_in_parms;
		   var pts_out : pts_out_parms;
		   translate : boolean); external;


function appl_find(var filename : string) : integer;
{ AES call 13 : find application id of process with file name FILENAME }

begin
new(addr_in[0]);
addr_in[0]^ := filename;
aes_call(13, int_in, int_out, addr_in, addr_out);
appl_find := int_out[0];
dispose(addr_in[0]]
end;



function appl_read(app_id : integer:
		   msg_length : integer:
		   var message : string) : integer;
{ AES call 11 : read MESSAGE_LENGTH characters out of the message buffer
  of application APP_ID }

begin
new(addr_in[0]);
int_in[0] := app_id;
int_in[1] := msg_length;
aes_call(11, int_in, int_out, addr_in, addr_out);
message := addr_in[0]^;
appl_read := int_out[0];
end;



function appl_write(app_id : integer:
		   msg_length : integer:
		   var message : string) : integer;
{ AES call 12 : write MESSAGE_LENGTH characters into the message buffer
  of application APP_ID }

begin
new(addr_in[0]);
addr_in[0]^ := message;
int_in[0] := app_id;
int_in[1] := msg_length;
aes_call(12, int_in, int_out, addr_in, addr_out);
appl_write := int_out[0];
end;




A1.PAS
------

.
.
.
const app_file_name = 'MSG_ACC.ACC';

{$Iapp.inc}
.
.
.
begin
my_app_id := init_gem;
name := app_file_name;

if my_app_id>0 then
	begin
	.
	.
	.
	m := 'Message from A1';
	app_id := appl_find(name);
	status := appl_write(app_id, 15, m);
	.
	.
	.
	exit_gem
	end
end.



MSG_ACC.PAS
-----------


.
.
.

{$Iapp.inc}
.
.
.
begin
my_app_id := init_gem;
.
.
.
{...in event loop...}
status := appl_read(my_app_id, 80, message);
.
.
.



Another way is to use the AES clipboard (not 'scratchpad', sorry).
These programs still work with the old compiled .PRG's.


procedure scrp_read(var message : string);
{ AES call 80 : read string from clipboard }

begin
new(addr_in[0]);
aes_call(80, int_int, int_out, addr_in, addr_out);
message( := addr_in[0]^
end;


procedure scrp_write(var message : string);
{ AES call 81 : write string to clipboard }

begin
new(addr_in[0]);
aes_call(81, int_int, int_out, addr_in, addr_out);
end;



P1.PAS
------

.
.
.
begin
.
.
.
m := 'Message from P1';
scrp_write(m);
.
.
.
end.




P2.PAS
------

{ start it after P1.PRG has finished }
.
.
.
begin
.
.
.
scrp_read(m);
writeln(m);
.
.
.
end.



22.7Alternate parameter file?THE780::MESSENGERAn Index of MetalsFri Apr 08 1988 16:519
< Note 22.4 by BOLT::MINOW "Je suis marxiste, tendance Groucho" >

>There's also a (badly documented) pair of routines that, as far as
>I can tell, read and write the in-memory representation of DESKTOP.INF.
>They're called shel_get and shel_put.  I use them in my terminal emulator

    Hmmm, does this mean I could use those functions to invoke an alternate
    DESKTOP.INF after system boot?
    				- HBM