![]() |
![]() |
#1 |
Registered User
Join Date: Jul 2009
Location: Lala Land
Posts: 608
|
readch and ctrl+c
I've got a script that loops on READCH('serial') but it does not respond to Ctrl+c. Whether the default handling or a custom SIGNAL handler.
My assumption is that READCH('serial') is a blocking call and it prevents the arexx signal handler from being run. Sound correct? Is there a way to get around this? I tried polling EOF('serial') before doing a READCH, but it always returns 0 even if nothing has been sent. |
![]() |
![]() |
#2 |
Registered User
Join Date: Oct 2009
Location: Germany
Posts: 3,326
|
Can you show the script? What is the meaning of "READCH('serial')"? 'serial' can be everything that is opened before. So is it SER: device or what? A normal READCH() from a file will break by a CTRL+C but I do not know if read from SER: is different.
|
![]() |
![]() |
#3 |
Registered User
Join Date: Jan 2002
Location: Germany
Posts: 7,047
|
No, it won't. READCH will indeed block until the requested character is received. Only then the script can check for Ctrl-C and stop if need be.
dos.library has a WaitForChar function for this purpose which will return after a given amount of time if no character is received. But I don't know if any ARexx function utilises it. |
![]() |
![]() |
#4 |
Registered User
Join Date: Jan 2019
Location: Germany
Posts: 3,495
|
The port-handler from 3.2 also has a non-blocking option for SER:. In such a case, an attempt to read returns 0 bytes. That is the option NOWAIT in the path.
|
![]() |
![]() |
#5 |
Registered User
Join Date: Oct 2009
Location: Germany
Posts: 3,326
|
Ok, I've only tested the working condition of READCH(). I guess a read from a file will always work.
So how can READCH() fail or wait for character for ever? Maybe reading from SER: means there is no EOF or similar condition (stream without any size/end information)? If so I also don't see any ARexx function that will help if nothing is returned and therefore you cannot respond to. There is SIGNAL ON IOERR but if no error is received it will not help. ARexxGuide2 has some I/O examples but if they can help? Maybe there is an external library with such WaitForChar function but I don't know any. |
![]() |
![]() |
#6 |
Registered User
Join Date: Jan 2019
Location: Germany
Posts: 3,495
|
See RKRM DOS:
https://github.com/thorfdbg/rkrm-dos/blob/main/dos.pdf section 12.3. SER: implements a blocking read, unless you tell it not to block. See also the above reference. READCH is, unless you configure your stream carefully, not the right option. |
![]() |
![]() |
#7 | |
Registered User
Join Date: Jul 2009
Location: Lala Land
Posts: 608
|
Quote:
If I come back to it I'll check out the port handler and upgrade to 3.2. |
|
![]() |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
Thread Tools | |
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Can't see HDD after pressing ctrl + a + a | Raffaz | support.Hardware | 3 | 20 June 2021 15:48 |
Take control of Alt + TAB, Ctrl + Alt + Del and Ctrl + ESC. | Ponki1986 | support.WinUAE | 6 | 13 December 2020 07:54 |
Right CTRL as fire | chip | request.UAE Wishlist | 6 | 15 June 2018 16:09 |
Problems with Ctrl + A + A. | ss2180 | support.Hardware | 6 | 10 April 2017 16:49 |
Where is Amiga CTRL+c (d, e, f)? | hexaae | support.WinUAE | 7 | 03 June 2007 11:50 |
|
|