[racket] accessing serial communications on Racket/Windows?...

From: Rüdiger Asche (rac at ruediger-asche.de)
Date: Tue Mar 13 12:20:12 EDT 2012

Thanks, that sort of works, but only sort of... here is the portmon  
trace - it turns out that the open won't quite work, and nothing is  
output until the port is being closed - looks like some setup of the  
port is missing (eg setting output buffer size). Is there any more  
info available on that? I understand that communications are always a  
pitb to implement; lots of OS specific issues and device specific trap  
doors to fall into, so if that's not sufficiently covered, I'll have  
to think of something else...

Thanks for the ultrafast response!

btw, I was aware of the double slash/backslash issue, just omitted it  
in the initial post for readablitie's sake. I remembered that in other  
contexts, the backslashes are rejected by Racket, so it didn't occur  
to me that it might work here...

7	17:12:28	Racket.exe	IRP_MJ_CREATE	VCP0	SUCCESS	Options: Create
8	17:12:28	Racket.exe	IRP_MJ_QUERY_VOLUME_INFORMATION	VCP0	INVALID  
DEVICE REQUEST
9	17:13:28	Racket.exe	IRP_MJ_WRITE	VCP0	SUCCESS	Length 16: 33 33 33 33  
33 33 33 33 33 33 33 33 33 33 33 33
10	17:13:28	Racket.exe	IRP_MJ_CLEANUP	VCP0	SUCCESS
11	17:13:28	Racket.exe	IRP_MJ_CLOSE	VCP0	SUCCESS


Quoting PM responder:

> Try using backslashes instead of forward slashes-- "\\\\.\\com1". And
> you need doubled backslashes because \ is an escape character in the
> string.
>
> On Tue, Mar 13, 2012 at 12:00 PM, Rüdiger Asche   
> <rac at ruediger-asche.de> wrote:
>>
>> Hello,
>>
>> Section 12.1.5 of the docs suggests that it should be possible to   
>> use file ports for accessing serial communications, such as
>>
>> (define-values (inport outport) (open-input-output-file "com1"))
>>
>> That works, but
>>
>>> inport
>>
>>
>> #<input-port:c:\personal\racket\v1.1\com1>
>>
>> and likewise
>>
>>> outport
>>
>>
>> #<output-port:c:\personal\racket\v1.1\com1>
>>
>> which means in theory and practice that Racket creates a file   
>> called com1 in that directory to which the I/O is performed instead  
>>  of using the serial port. I tried uppercase and lowercase as well   
>> as /./COM1, all with the same results (except that sometimes the   
>> port was created in the root). So how does the file name have to be  
>>  specified to redirect the I/O to a serial port?
>>
>> On a related note, is it possible to access/set the comm parameters  
>>  (baud rate, handshaking and so on) of a specified port using Racket?
>>
>> Thanks again.
>>
>>
>>
>> ____________________
>>  Racket Users list:
>>  http://lists.racket-lang.org/users
>
>





Posted on the users mailing list.