English Amiga Board


Go Back   English Amiga Board > Coders > Coders. System > Coders. Scripting

 
 
Thread Tools
Old 01 June 2024, 01:59   #1
copse
Registered User
 
Join Date: Jul 2009
Location: Lala Land
Posts: 601
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.
copse is offline  
Old 01 June 2024, 14:21   #2
daxb
Registered User
 
Join Date: Oct 2009
Location: Germany
Posts: 3,307
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.
daxb is online now  
Old 01 June 2024, 15:40   #3
thomas
Registered User
 
thomas's Avatar
 
Join Date: Jan 2002
Location: Germany
Posts: 7,025
Quote:
Originally Posted by daxb View Post
A normal READCH() from a file will break by a CTRL+C
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.
thomas is offline  
Old 01 June 2024, 18:05   #4
Thomas Richter
Registered User
 
Join Date: Jan 2019
Location: Germany
Posts: 3,306
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.
Thomas Richter is offline  
Old 01 June 2024, 18:26   #5
daxb
Registered User
 
Join Date: Oct 2009
Location: Germany
Posts: 3,307
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.
daxb is online now  
Old 01 June 2024, 21:17   #6
Thomas Richter
Registered User
 
Join Date: Jan 2019
Location: Germany
Posts: 3,306
Quote:
Originally Posted by daxb View Post
So how can READCH() fail or wait for character for ever?
See RKRM DOS:

https://github.com/thorfdbg/rkrm-dos/blob/main/dos.pdf

section 12.3.

Quote:
Originally Posted by daxb View Post
Maybe reading from SER: means there is no EOF or similar condition (stream without any size/end information)?
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.
Thomas Richter is offline  
Old 01 June 2024, 22:06   #7
copse
Registered User
 
Join Date: Jul 2009
Location: Lala Land
Posts: 601
Quote:
Originally Posted by Thomas Richter View Post
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.
Thanks Thomas. Good to know. I thought Arexx might have been the simplest way to play around with reading from the serial port, but it took me ages to work out that at least the version I was using was erroring because I didn't have a comment at the top and working because I put a comment there by happenstance! Crikey, I wonder how much user time that design decision wasted over the years.

If I come back to it I'll check out the port handler and upgrade to 3.2.
copse is offline  
 


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Similar Threads
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

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 13:55.

Top

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Page generated in 0.09405 seconds with 15 queries