Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

202
Visualizações
Why my CGI Script can't access to ttyUSB0?

I'm having a CGI script in C language, which open the serial port ttyUSB0 in my Raspberry pi, send a data at my device and get it response.

This script perform correctly when i'm launch it manually in the terminal but my web page can't access to this port to open it.

My code :

int main (void) {

  printf("Content-type: text/html\n\n");

  const int fd = open ("/dev/ttyUSB0", O_RDWR | O_NOCTTY | O_SYNC);

  if (fd == -1)
  {
        printf ("error %d opening %s: %s", errno, "ttyUSB0", strerror (errno));
        return 0;
  }

And the response in the web page : "error 13 opening ttyUSB0: Permission denied"

And below the output of the command "id -Gn pi" : pi adm tty uucp dialout cdrom sudo audio video plugdev games users input netdev spi i2c gpio lpadmin

Thanks.

over 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

The command below solved my problem :

sudo adduser www-data dialout
over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda