[an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] (none) [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] (none) [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive]
 
[an error occurred while processing this directive] [an error occurred while processing this directive]
Skåne Sjælland Linux User Group - http://www.sslug.dk Home   Subscribe   Mail Archive   Forum   Calendar   Search
MhonArc Date: [Date Prev] [Date Index] [Date Next]   Thread: [Date Prev] [Thread Index] [Date Next]   MhonArc
 

Re: [PROGRAMMERING] Læse én karakter frattyS0



On Wed, 30 Jun 2004 22:22:53 +0200
Michael Bernhard Sørensen <sslug@sslug> wrote:

> 
> Svaret der kommer tilbage, er altid kun én karakter, læser jeg med
> kommandoen "cat /dev/ttyS0" og jeg får det tilbage som jeg forventer.

Får du 1 bogstav og så stopper cat? Har du gjort noget særligt med
S0 via stty kommandoen eller andet setup?

> Jeg skal hente denne ene karakter over i et script/program til senere
> behandling. Men hvordan gør jeg det?

Som Bjørn siger, kan du lægge output fra et program i en shell-var.

Hvis ikke cat /dev/something kan klare at læse 1 tegn ad gangen
må du skrive et lille C-program, som kan dette. Det kræver
manipulering af ioctl, svarende til en stty option - av uha!
Nu kan jeg sandelig ikke lige finde, hvad det er for en option,
jeg prøver med stty raw < /dev/ttyS0

Jeg vender tilbage, hvis jeg finder koden til "read 1 char setup"
altså non-buffered read.

Jeg nok at der tidligere har været koden til et sådant program her
på denne liste eller dens forgænger, C-programmering. Ellers har
jeg kode /library som kan bruges meget nemt, setrawio() og resetrawio().


/Hilsen

-- 
donald_j_axel donax snabela get2net.dk -- http://d-axel.dk/


 
Home   Subscribe   Mail Archive   Index   Calendar   Search

 
 
Questions about the web-pages to <www_admin>. Last modified 2005-08-10, 22:44 CEST [an error occurred while processing this directive]
This page is maintained by [an error occurred while processing this directive]MHonArc [an error occurred while processing this directive] # [an error occurred while processing this directive] *