[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] C og seriel port (USB)



Hans Schou wrote:

> On Mon, 24 Jan 2011, Henrik Pedersen wrote:
> 
>>    //    cfsetispeed(&oldtio, B2400); // set baud rates
>>    //    cfsetospeed(&oldtio, B2400);
>>    oldtio.c_cflag &= ~PARENB; // set no parity, stop bits, data bits
>>    oldtio.c_cflag &= ~CBAUD;
>>    oldtio.c_cflag |= B2400;
>>    oldtio.c_cflag |= CS8;
>>    tcsetattr(fdPort, TCSANOW, &oldtio); // apply the settings to the port
>>
>> Gode bud søges ?
> 
> Det er ikke mange flags du ændre, se fx:
> http://schou.dk/linux/sartorius/sartorius.c
> (det er min vægt)
> 
> I anden sammenhæng hvor det er en ftdi_sio vej bruger. Det er en
> serial til USB converter dims:
> http://schou.dk/linux/usbio24/usbio24a.c
>                  ioctl(fd, TCGETS, &term);
>                  term_orig = term;  /* det gør minicom ikke */
>                  term.c_iflag &= ~( ICRNL );
>                  term.c_oflag &= ~( ONLCR );
>                  term.c_lflag &= ~( ICANON | ISIG | ECHO );
>                  ioctl(fd, TCSETS, &term);
> 
> 
> Tidligere har jeg haft held med at bruge minicom til test, og her er
> det så heldigt at minicom ikke restore de gamle værdier under exit, og
> så har jeg aflæst med setserial (noget dump et-eller-andet).
> 
> Hvis ikke du kan finde setserial, så bruge denne
> http://schou.dk/linux/c/tcattr.c
> den gør det samme.
> 
> /hans

Hej Hans

Jeg går ud fra tcgetattr og tcsetattr erstatter ioctl uden problemer.
Har prøvet at koble nogle af díne settings på uden den store succes.
Når jeg forsøger at læse fra porten med 
byteCount = read(fdPort, buffer, 255);
returnere read -1, og errno er 11, når jeg så fører et tag over skifter 
errno til 14.
Jeg kan dælme ikke hitte ud af hvad der går galt.

Nu har jeg dog fundet af at stty -F /dev/ttyUSB0 fortæller mig hvordan 
porten er konfigureret, og kan i den forbindelse se om baudrate med mere 
bliver sat. 
RFID readerens manual siger følgende:
Communication Protocol
All communication is 8 data bits, no parity, 1 stop bit, and least 
significant bit first (8N1) at 2400 bps.

Hvordan får jeg sat det, og hvad betyder fejlkoderne ?

\Henrik


 
Home   Subscribe   Mail Archive   Index   Calendar   Search

 
 
Questions about the web-pages to <www_admin>. Last modified 2011-02-01, 02:01 CET [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] *