Discussion:
Problem returning from WGET from within an assembler prog
(too old to reply)
Bob Latham
2022-04-08 11:07:09 UTC
Permalink
Hi,

I've written a program that works as two separate chunks but I cannot
find a way to add the chunks together.

My little program (assembler and not wimp) firstly uses WGET to down
load a file from the interweb. This is done in a subroutine where SWI
"OS_CLI" R0 points at a string with WGET in it and the file downloads
no problem. When it returns from the subroutine, the program then
*should* use the downloaded data to produce another angle on the data.

The two parts work fine apart but I can't join them together. It's
that the cpu isn't returning from the subroutine in the way I
expected and seems determined to stop the whole thing with "press
space bar" etc. it will not carry on with my program.

I know there is something I'm not understanding here, could someone
enlighten me please.

Thanks.

Bob.
Steve Drain
2022-04-08 12:08:44 UTC
Permalink
Hi,I've written a program that works as two separate chunks but I cannotfind a way to add the chunks together.My little program (assembler and not wimp) firstly uses WGET to download a file from the interweb. This is done in a subroutine where SWI"OS_CLI" R0 points at a string with WGET in it and the file downloadsno problem. When it returns from the subroutine, the program then*should* use the downloaded data to produce another angle on the data.The two parts work fine apart but I can't join them together. It'sthat the cpu isn't returning from the subroutine in the way Iexpected and seems determined to stop the whole thing with "pressspace bar" etc. it will not carry on with my program. I know there is something I'm not understanding here, could someoneenlighten me please.Thanks.Bob.
I woud guess Wimp_StartTask rather OS_CLI to avoid overwriting
your application space.


----Android NewsGroup Reader----
https://piaohong.s3-us-west-2.amazonaws.com/usenet/index.html
Bob Latham
2022-04-08 16:33:51 UTC
Permalink
Post by Steve Drain
I woud guess Wimp_StartTask rather OS_CLI to avoid overwriting
your application space.
Thanks Steve. That gives me something to read up about.

I don't understand what overwrites the application space though.


Bob.
Harriet Bazley
2022-04-08 17:07:23 UTC
Permalink
On 8 Apr 2022 as I do recall,
Post by Bob Latham
Post by Steve Drain
I woud guess Wimp_StartTask rather OS_CLI to avoid overwriting
your application space.
Thanks Steve. That gives me something to read up about.
I don't understand what overwrites the application space though.
As I understand it, when you use OSCLI to start a new application
directly then control never returns to the original program - you are
executing the equivalent of a GOTO rather than a PROC.

(Unless, apparently, you have a 'quit handler':
http://www.verycomputer.com/24_f48d3602910d170e_1.htm )

Wimp_StartTask launches it as an independent task with its own Wimpslot,
etc (although it also means that your program won't wait for this new
task to return before continuing on with its own next instruction - and
in the case of a wget command, I imagine that the result might
potentially take quite a while).
--
Harriet Bazley == Loyaulte me lie ==

Abstinence makes the heart grow fonder.
Bob Latham
2022-04-08 19:05:39 UTC
Permalink
Post by Harriet Bazley
As I understand it, when you use OSCLI to start a new application
directly then control never returns to the original program - you
are executing the equivalent of a GOTO rather than a PROC.
http://www.verycomputer.com/24_f48d3602910d170e_1.htm )
Wimp_StartTask launches it as an independent task with its own
Wimpslot, etc (although it also means that your program won't wait
for this new task to return before continuing on with its own next
instruction - and in the case of a wget command, I imagine that the
result might potentially take quite a while).
Thanks for that. I really have got something to chew on now.

Cheers,

Bob.
Bob Latham
2022-04-09 11:15:28 UTC
Permalink
Post by Harriet Bazley
Wimp_StartTask launches it as an independent task with its own
Wimpslot, etc (although it also means that your program won't wait
for this new task to return before continuing on with its own next
instruction - and in the case of a wget command, I imagine that the
result might potentially take quite a while).
Naively I tried this with fingers crossed.

I get an error..

'Invalid Wimp operation in this context.'


Clearly this is way beyond my understanding.

Bob.
Steve Fryatt
2022-04-09 13:10:44 UTC
Permalink
On 9 Apr, Bob Latham wrote in message
Post by Bob Latham
'Invalid Wimp operation in this context.'
Ah. Wimp_StartTask must be called from a Wimp application which is already
calling Wimp_Poll.

I think your options are either to look at the Arthur way of doing stuff
(fiddle with the environment and shift things around in memory) or do
without WGet.

If you're using RISC OS 5, could you use the built-in HTTP fetcher? As a
module called by SWIs, that might run as part of your application (I don't
know; I've not looked at how it works, so I'm not sure if it expects to be
called from a polling application or not). If so, that would sidestep the
problem of launching a separate task to do the fetching.
--
Steve Fryatt - Leeds, England

http://www.stevefryatt.org.uk/
Bob Latham
2022-04-09 16:55:42 UTC
Permalink
Post by Steve Fryatt
On 9 Apr, Bob Latham wrote in message
Post by Bob Latham
'Invalid Wimp operation in this context.'
Ah. Wimp_StartTask must be called from a Wimp application which is
already calling Wimp_Poll.
I think your options are either to look at the Arthur way of doing
stuff (fiddle with the environment and shift things around in
memory) or do without WGet.
If you're using RISC OS 5, could you use the built-in HTTP fetcher?
As a module called by SWIs, that might run as part of your
application (I don't know; I've not looked at how it works, so I'm
not sure if it expects to be called from a polling application or
not). If so, that would sidestep the problem of launching a
separate task to do the fetching.
Thanks Steve.

I did look into that but quickly realised this is beyond my baby
steps.

Must admit, it surprises me that fetching a file from the net is so
difficult to do.

Thanks again.

Bob.
Kevin Wells
2022-04-09 19:23:39 UTC
Permalink
Post by Bob Latham
Post by Steve Fryatt
On 9 Apr, Bob Latham wrote in message
Post by Bob Latham
'Invalid Wimp operation in this context.'
Ah. Wimp_StartTask must be called from a Wimp application which is
already calling Wimp_Poll.
I think your options are either to look at the Arthur way of doing
stuff (fiddle with the environment and shift things around in
memory) or do without WGet.
If you're using RISC OS 5, could you use the built-in HTTP fetcher?
As a module called by SWIs, that might run as part of your
application (I don't know; I've not looked at how it works, so I'm
not sure if it expects to be called from a polling application or
not). If so, that would sidestep the problem of launching a
separate task to do the fetching.
Thanks Steve.
I did look into that but quickly realised this is beyond my baby
steps.
Must admit, it surprises me that fetching a file from the net is so
difficult to do.
From BASIC wget is easy to fetch files from the internet I use the
followiong:

SYS "Wimp_StartTask", "wget ...

Whilst fetching the computer is single tasking,
Post by Bob Latham
Thanks again.
Bob.
--
Kev Wells
http://kevsoft.co.uk/ https://ko-fi.com/kevsoft
carpe cervisium
24 hours in a day and 24 beers in a case. Hmmm..
David Higton
2022-04-09 21:29:18 UTC
Permalink
Post by Kevin Wells
Post by Bob Latham
Post by Steve Fryatt
On 9 Apr, Bob Latham wrote in message
Post by Bob Latham
'Invalid Wimp operation in this context.'
Ah. Wimp_StartTask must be called from a Wimp application which is
already calling Wimp_Poll.
I think your options are either to look at the Arthur way of doing
stuff (fiddle with the environment and shift things around in memory)
or do without WGet.
If you're using RISC OS 5, could you use the built-in HTTP fetcher? As
a module called by SWIs, that might run as part of your application (I
don't know; I've not looked at how it works, so I'm not sure if it
expects to be called from a polling application or not). If so, that
would sidestep the problem of launching a separate task to do the
fetching.
Thanks Steve.
I did look into that but quickly realised this is beyond my baby steps.
Must admit, it surprises me that fetching a file from the net is so
difficult to do.
From BASIC wget is easy to fetch files from the internet I use the
SYS "Wimp_StartTask", "wget ...
Whilst fetching the computer is single tasking,
Similarly, my UpdCaCert app launches curl by means of Wimp_StartTask,
and the resukt single-tasks for a few seconds.

So it's not difficult, really, but you do need to know some important
bits of information. One is that you can't do Wimp operations except
from a registered Wimp task; another is that, in most cases, you can't
just do *OSCLI for an app because the new app will wipe out the app that
launched it.

David
Bob Latham
2022-04-10 08:38:45 UTC
Permalink
Post by David Higton
So it's not difficult, really, but you do need to know some
important bits of information. One is that you can't do Wimp
operations except from a registered Wimp task; another is that, in
most cases, you can't just do *OSCLI for an app because the new app
will wipe out the app that launched it.
So I've learned painfully this week. :-)

Thanks.

Bob.
Bob Latham
2022-04-10 08:36:57 UTC
Permalink
Post by Kevin Wells
Post by Steve Fryatt
Ah. Wimp_StartTask must be called from a Wimp application which
is already calling Wimp_Poll.
From BASIC wget is easy to fetch files from the internet I use the
SYS "Wimp_StartTask", "wget ...
Whilst fetching the computer is single tasking,
When you say "Basic", I'm starting to think you mean a full wimp
application written in Basic?

Thanks.

Bob.
Kevin Wells
2022-04-10 12:05:55 UTC
Permalink
Post by Bob Latham
Post by Kevin Wells
Post by Steve Fryatt
Ah. Wimp_StartTask must be called from a Wimp application which
is already calling Wimp_Poll.
From BASIC wget is easy to fetch files from the internet I use the
SYS "Wimp_StartTask", "wget ...
Whilst fetching the computer is single tasking,
When you say "Basic", I'm starting to think you mean a full wimp
application written in Basic?
Yes under DR Wimp

Another method I used in my QrCode application is to create an Obey file
with just wget ... in it file typed as FEB so that I can have more than
256 characters in it. If going down that route then anything with a % in
it will need %%
Post by Bob Latham
Thanks.
Bob.
--
Kev Wells
http://kevsoft.co.uk/ https://ko-fi.com/kevsoft
carpe cervisium
O it's Tommy this, an' Tommy that, an' " Tommy, go away " ;
Kevin Wells
2022-04-11 17:09:14 UTC
Permalink
Post by Kevin Wells
Post by Bob Latham
Post by Kevin Wells
Post by Steve Fryatt
Ah. Wimp_StartTask must be called from a Wimp application which
is already calling Wimp_Poll.
From BASIC wget is easy to fetch files from the internet I use the
SYS "Wimp_StartTask", "wget ...
Whilst fetching the computer is single tasking,
When you say "Basic", I'm starting to think you mean a full wimp
application written in Basic?
Yes under DR Wimp
Another method I used in my QrCode application is to create an Obey file
with just wget ... in it file typed as FEB so that I can have more than
256 characters in it. If going down that route then anything with a % in
it will need %%
After a few pints of insperation juice (beer) I think I have a plan for
multitaksing the the above.

There is an an obey file that returns to the computer very quickly I
can't remember which one at the top of my head.

So you select the logging switch to save the log info to file scrap
would be the best place, and in the polling loop check to see if that
file is there and when it is carry on.
Post by Kevin Wells
Post by Bob Latham
Thanks.
Bob.
--
Kev Wells
http://kevsoft.co.uk/ https://ko-fi.com/kevsoft
carpe cervisium
Bring me my bow of burning gold!
Harriet Bazley
2022-04-10 12:01:45 UTC
Permalink
On 9 Apr 2022 as I do recall,
Bob Latham wrote:

[snip]
Post by Bob Latham
Must admit, it surprises me that fetching a file from the net is so
difficult to do.
Doesn't surprise me - fetching a file across the Internet is an order of
complexity above fetching a file from the local hard disc, and in
addition you're launching an external application in order to do it,
which is quite a lot for a small assembler routine to handle....

You originally said that you had two separate working routines but
simply couldn't seem to paste them together - would it not be possible
to have a 'parent' BASIC file that could call them both in succession?

(Registering yourself as a WIMP task is not in fact that complicated,
and I don't think your program actually needs to implement a Wimp_Poll
loop if it is single-tasking and not attempting to interact with the
desktop in any way - I seem to remember writing some pretty crude
software that just called Wimp_Initialise claiming to be a RISC OS 2
application, executed a few lines of BASIC and then quit.)
--
Harriet Bazley == Loyaulte me lie ==

We prefer to speak evil of ourselves than not speak of ourselves at all.
Bob Latham
2022-04-10 12:36:24 UTC
Permalink
Post by Harriet Bazley
You originally said that you had two separate working routines but
simply couldn't seem to paste them together - would it not be
possible to have a 'parent' BASIC file that could call them both in
succession?
Possibly.
Post by Harriet Bazley
(Registering yourself as a WIMP task is not in fact that
complicated, and I don't think your program actually needs to
implement a Wimp_Poll loop if it is single-tasking and not
attempting to interact with the desktop in any way -
Interesting.
Post by Harriet Bazley
I seem to remember writing some pretty crude software that just
called Wimp_Initialise claiming to be a RISC OS 2 application,
executed a few lines of BASIC and then quit.)
Okay, thanks for that. I have written full wimp apps in Basic and in
assembler, I can do it but didn't feel it was needed for a simple
data grab from an html file.

Your half way idea looks promising.

Thanks.

Bob.
druck
2022-04-11 12:59:19 UTC
Permalink
Post by Harriet Bazley
Doesn't surprise me - fetching a file across the Internet is an order of
complexity above fetching a file from the local hard disc, and in
addition you're launching an external application in order to do it,
which is quite a lot for a small assembler routine to handle....
Classic wrong tool for the job. It Python it is one line of code using
the requests module. But of course we just need the requests module in
the RISC OS version of Python3 <arrrrh>.

---druck
Theo
2022-04-09 13:15:47 UTC
Permalink
Post by Bob Latham
Post by Harriet Bazley
Wimp_StartTask launches it as an independent task with its own
Wimpslot, etc (although it also means that your program won't wait
for this new task to return before continuing on with its own next
instruction - and in the case of a wget command, I imagine that the
result might potentially take quite a while).
Naively I tried this with fingers crossed.
I get an error..
'Invalid Wimp operation in this context.'
Clearly this is way beyond my understanding.
Wimp_StartTask only works if you're already in a Wimp task. That might be a
desktop app, or a command line app running in a TaskWindow. If you are
outside the desktop the Wimp isn't running so you can't launch other tasks.

Try your code in a Taskwindow?

Theo
Bob Latham
2022-04-09 16:56:26 UTC
Permalink
Post by Theo
Post by Bob Latham
Post by Harriet Bazley
Wimp_StartTask launches it as an independent task with its own
Wimpslot, etc (although it also means that your program won't wait
for this new task to return before continuing on with its own next
instruction - and in the case of a wget command, I imagine that the
result might potentially take quite a while).
Naively I tried this with fingers crossed.
I get an error..
'Invalid Wimp operation in this context.'
Clearly this is way beyond my understanding.
Wimp_StartTask only works if you're already in a Wimp task. That
might be a desktop app, or a command line app running in a
TaskWindow. If you are outside the desktop the Wimp isn't running
so you can't launch other tasks.
Try your code in a Taskwindow?
Thanks for the information.

Cheers,

Bob.
Post by Theo
Theo
Steve Fryatt
2022-04-08 18:15:06 UTC
Permalink
On 8 Apr, Bob Latham wrote in message
Post by Bob Latham
Post by Steve Drain
I woud guess Wimp_StartTask rather OS_CLI to avoid overwriting
your application space.
Thanks Steve. That gives me something to read up about.
I don't understand what overwrites the application space though.
WGet, which is an application that you've just started in application space.

RISC OS is a single tasking operating system with a thin veneer of fake
multi-tasking applied on top by the Wimp. As far as all of the non-Wimp bits
of the OS are concerned, applications reside at 0x8000. Since there can only
be one application at 0x8000 at a time, the act of launching WGet overwrites
and completely obliterates your application. This is why the subroutine can
never return: by that point, your application doesn't exist any more.

As Harriet notes, there are some messy work-arounds: either the old
Arthur-era one of shifting memory around, or the RISC OS-era one of passing
the problem to the Wimp.
--
Steve Fryatt - Leeds, England

http://www.stevefryatt.org.uk/
Bob Latham
2022-04-08 19:07:43 UTC
Permalink
Post by Steve Fryatt
WGet, which is an application that you've just started in
application space.
RISC OS is a single tasking operating system with a thin veneer of
fake multi-tasking applied on top by the Wimp. As far as all of the
non-Wimp bits of the OS are concerned, applications reside at
0x8000. Since there can only be one application at 0x8000 at a
time, the act of launching WGet overwrites and completely
obliterates your application. This is why the subroutine can never
return: by that point, your application doesn't exist any more.
As Harriet notes, there are some messy work-arounds: either the old
Arthur-era one of shifting memory around, or the RISC OS-era one of
passing the problem to the Wimp.
Thanks Steve,

Much appreciated.


Bob.
Loading...