Fwd: Re: C program to write to the com port - RESOLVED

Helge Preuss helge.preuss at gmx.net
Fri Sep 9 06:10:47 PDT 2005


vittorio wrote:

>[...]
>SerialPort.C: In function `int main(int, char*)':
>SerialPort.C:62: error: invalid conversion from `unsigned char*' to `char*'
>SerialPort.C:62: error:   initializing argument 1 of `int snprintf(char*, 
>size_t, const char*, ...)'
>SerialPort.C:66: error: `err' undeclared (first use this function)
>SerialPort.C:66: error: (Each undeclared identifier is reported only once for 
>each function it appears in.)
>SerialPort.C:69:3: warning: no newline at end of file
>
>Could you please help to straighten things up?
>  
>
A relevant line from man snprintf:
 > int snprintf(char *str, size_t size, const char *format, ...);
So you might want to change line 27 to
    char buf[4];
and perhaps line 62 too:

  snprintf(buf,4,"%c%c%c%c",(char)0xff,0x00,0x01,0);
another relevant line from man err:
>  #include <err.h>

HTH, haven't tried it

Helge




More information about the freebsd-questions mailing list