Bonjour,

Je travaille avec un pupitre de commande qui communique via un cable rs-232 et il possède un protocole bien spécifique créé par le constructeur, j'ai trouvé un code C sur internet via lequel je peux envoyer des commandes correspondant au protocole "datasheet du constructeur" le format des commandes est correcte et le code aussi. Mon problème c'est que mon pupitre n'arrive pas à lire les commande et quand je tape "dmesg" j'obtiens ce message.

[ 8702.516589] pl2303 ttyUSB0: pl2303_get_line_request - failed: -110
[ 8702.862487] pl2303 ttyUSB0: pl2303_set_line_request - failed: -110
[ 8703.516442] pl2303 2-2.3:1.0: pl2303_vendor_write - failed to write [0000]: -110
[ 8703.862878] pl2303 ttyUSB0: pl2303_set_control_lines - failed: -110
Voici mon code :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#include<string.h>
#include<stdlib.h>
#include<stdio.h>
#include<errno.h>
#include<unistd.h>
#include<fcntl.h>
#include<termio.h>
#include <time.h>
#include <linux/serial.h>
 
int serial_open(char *serial_name, speed_t baud)
{
struct termios options;
      int fd;
   	fd = open("/dev/ttyUSB0",O_RDWR);
	tcgetattr(fd, &options);
	printf("fd %d\n",fd);
	cfsetospeed(&options, baud); 
	options.c_cflag &= ~PARENB; 
	options.c_cflag &= ~CSTOPB; 
	options.c_cflag &= ~CSIZE;
	options.c_cflag |= CS8 | CLOCAL; 
	options.c_lflag = ICANON; 
	options.c_oflag &= ~OPOST; 
 
	tcsetattr(fd, TCSANOW, &options); 
	tcflush(fd, TCOFLUSH);
 
    	close(fd);
}
void serial_send(int serial_fd, char *data, int nbyte  )
{
  write(serial_fd, data, nbyte);
}
 
int main() {
    int serial_fd;
   char *device;
 
int nbyte = 28;
 
    /* Open and configure serial port */
 
   serial_fd = serial_open("/dev/ttyUSB0",B9600);
        serial_send(serial_fd, device, nbyte);
printf("Ecrire la commande : \n");
scanf("%s",device);
sleep(6);
        printf ("\nCommande envoyé %s\n",device);
sleep(6);
    return 0;
}
Merci d'avance pour votre aide !