Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
q. on reading bytes from "BIDIRECTIONAL-TERMINAL-STREAM"
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  8 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Richard James Panturis Giuly  
View profile  
 More options Aug 21 2000, 3:00 am
Newsgroups: comp.lang.lisp
From: Richard James Panturis Giuly <n...@spam.com>
Date: 2000/08/21
Subject: q. on reading bytes from "BIDIRECTIONAL-TERMINAL-STREAM"
In ACL on Linux, I use run-shell-command to start a process that
generates output to stdout. I can read from the stream that
run-shell-command returns with read-char but I need to be reading
bytes, not characters. When I try to use read-byte it says

Error: No methods applicable for generic function
       #<STANDARD-GENERIC-FUNCTION STREAM-READ-BYTE> with args
       (#<BIDIRECTIONAL-TERMINAL-STREAM  fd 16/15 @ #x20256dca>)
of classes
       (BIDIRECTIONAL-TERMINAL-STREAM)

how can I read bytes instead efficiently?

--
        ricky
        rgi...@surfsouth.com


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Lieven Marchand  
View profile  
 More options Aug 22 2000, 3:00 am
Newsgroups: comp.lang.lisp
From: Lieven Marchand <m...@bewoner.dma.be>
Date: 2000/08/22
Subject: Re: q. on reading bytes from "BIDIRECTIONAL-TERMINAL-STREAM"
Richard James Panturis Giuly <n...@spam.com> writes:

> In ACL on Linux, I use run-shell-command to start a process that
> generates output to stdout. I can read from the stream that
> run-shell-command returns with read-char but I need to be reading
> bytes, not characters. When I try to use read-byte it says

> Error: No methods applicable for generic function
>        #<STANDARD-GENERIC-FUNCTION STREAM-READ-BYTE> with args
>        (#<BIDIRECTIONAL-TERMINAL-STREAM  fd 16/15 @ #x20256dca>)
> of classes
>        (BIDIRECTIONAL-TERMINAL-STREAM)

> how can I read bytes instead efficiently?

On Unix, character streams and byte streams are fairly
interchangeable. Have you measured READ-CHAR is actually slower than
READ-BYTE?

If this is really the case, you could try doing a CHANGE-CLASS on your
stream to BIDIRECTIONAL-BINARY-SOCKET-STREAM. Alternatively, you can
create your own binary stream and give that as argument to the :output
key argument of RUN-SHELL-COMMAND.

--
Lieven Marchand <m...@bewoner.dma.be>
Lambda calculus - Call us a mad club


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Erik Naggum  
View profile  
 More options Aug 22 2000, 3:00 am
Newsgroups: comp.lang.lisp
From: Erik Naggum <e...@naggum.net>
Date: 2000/08/22
Subject: Re: q. on reading bytes from "BIDIRECTIONAL-TERMINAL-STREAM"
* Richard James Panturis Giuly <n...@spam.com>
| how can I read bytes instead efficiently?

  Which inefficient solutions have you tried so far?  (Since you use
  one of those extremely annoying invalid return addresses, I'm not
  inclined to provide you with the solution I used ere the dawn of
  bivalent¹ streams in Allegro CL.)

#:Erik
-------
¹ "multivalent" in recent terminology change, but it sounds silly
--
  If this is not what you expected, please alter your expectations.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Richard James Panturis Giuly  
View profile  
 More options Aug 22 2000, 3:00 am
Newsgroups: comp.lang.lisp
From: Richard James Panturis Giuly <n...@spam.com>
Date: 2000/08/22
Subject: Re: q. on reading bytes from "BIDIRECTIONAL-TERMINAL-STREAM"
When I convert the input stream to an INPUT-BINARY-SOCKET-STREAM,
the read-byte function works but still gives characters. I need
integers (or numbers of some kind) rather than characters.

I don't know how to create a binary stream, could you fill me in?
(All I found were functions to make streams from existing
streams.)

If you know how I can convert a character to an integer that
would be fine too, I just thought converting every byte might be
inefficient.

> On Unix, character streams and byte streams are fairly
> interchangeable. Have you measured READ-CHAR is actually slower than
> READ-BYTE?
> If this is really the case, you could try doing a CHANGE-CLASS on your
> stream to BIDIRECTIONAL-BINARY-SOCKET-STREAM. Alternatively, you can
> create your own binary stream and give that as argument to the :output
> key argument of RUN-SHELL-COMMAND.

--
        ricky
        rgi...@surfsouth.com

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Tim Bradshaw  
View profile  
 More options Aug 23 2000, 3:00 am
Newsgroups: comp.lang.lisp
From: Tim Bradshaw <t...@cley.com>
Date: 2000/08/23
Subject: Re: q. on reading bytes from "BIDIRECTIONAL-TERMINAL-STREAM"
* Richard James Panturis Giuly wrote:

> If you know how I can convert a character to an integer that
> would be fine too, I just thought converting every byte might be
> inefficient.

CHAR-CODE gets the code of a character.  It's unlikely to be
inefficient compared to doing I/O.

--tim


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Erik Naggum  
View profile  
 More options Aug 23 2000, 3:00 am
Newsgroups: comp.lang.lisp
From: Erik Naggum <e...@naggum.net>
Date: 2000/08/23
Subject: Re: q. on reading bytes from "BIDIRECTIONAL-TERMINAL-STREAM"
* Richard James Panturis Giuly <n...@spam.com>
| If you know how I can convert a character to an integer that would
| be fine too, I just thought converting every byte might be
| inefficient.

  The function char-code returns the integer code of the character.
  It's essential a type-changing function, as both characters and
  integers are immediate values, and at least in Allegro CL is a
  simple bit-shift operation if you declare the character's type.

#:Erik
--
  If this is not what you expected, please alter your expectations.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Lieven Marchand  
View profile  
 More options Aug 23 2000, 3:00 am
Newsgroups: comp.lang.lisp
From: Lieven Marchand <m...@bewoner.dma.be>
Date: 2000/08/23
Subject: Re: q. on reading bytes from "BIDIRECTIONAL-TERMINAL-STREAM"
Richard James Panturis Giuly <n...@spam.com> writes:

> I don't know how to create a binary stream, could you fill me in?
> (All I found were functions to make streams from existing
> streams.)

I still think you're optimizing something that will be lost in the
fringe, but one way to do it is like this:

(defun test-function ()
  (let ((stream (open "/tmp/foo"
                      :direction :io
                      :if-exists :supersede
                      :element-type 'unsigned-byte))
        (output-buffer (make-array 1024 :element-type 'unsigned-byte)))
    (run-shell-command "ls" :output stream)
    (file-position stream 0)
    (read-sequence output-buffer stream)
    (close stream)
    output-buffer))

Add all apropriate declarations and this could be quite fast.

USER(35): (setf *foo* (test-function))
#(35 46 110 101 119 115 114 99 45 108 ...)

USER(39): (loop for c across *foo*
                collect (code-char c))
(#\# #\. #\n #\e #\w #\s #\r #\c #\- #\l ...)

--
Lieven Marchand <m...@bewoner.dma.be>
Lambda calculus - Call us a mad club


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Erik Naggum  
View profile  
 More options Aug 25 2000, 3:00 am
Newsgroups: comp.lang.lisp
From: Erik Naggum <e...@naggum.net>
Date: 2000/08/25
Subject: Re: q. on reading bytes from "BIDIRECTIONAL-TERMINAL-STREAM"
* Lieven Marchand <m...@bewoner.dma.be>
| USER(39): (loop for c across *foo*
|               collect (code-char c))
| (#\# #\. #\n #\e #\w #\s #\r #\c #\- #\l ...)

  (map 'list #'char-code <sequence>)

#:Erik
--
  If this is not what you expected, please alter your expectations.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »