Hi all,
I would communicate with an IHM by my BBB, the BBB is connected to my pc by the USB client and i have a little electronic card containing 2 port COM connected on my BBB by the USB host.
So i have see than the BBB is connected to the PC by the port COM13 and i have make a little program for communicate with the IHM:
the program:
#include
#include <stdio.h>
#include <termios.h>
#include <unistd.h>
#include <stdlib.h>
#include <fcntl.h>
#include <string.h>
int main()
{
char buffer[8]= “”;
struct termios options;
int fd,reception;
std::string code = “”;
unsigned char nombre =0x01;
char P1_Etat = 0x00;
//char[] P1_Led new char[3]={ 0x01, 0x00, 0x00 };
char c;
fd=open(“COM13”,O_RDWR | O_NOCTTY| O_NDELAY);
if(fd<0)
{
printf(“problème port serie\n”);
exit(-1);
}
else
{
printf(“port serie %d ouvert\n”,fd);
tcgetattr(fd,&options);
cfsetospeed(&options, B9600);
options.c_cflag |= (CLOCAL | CREAD);
options.c_cflag &= ~PARENB;
options.c_cflag &= ~CSTOPB;
options.c_cflag &= ~CSIZE;
options.c_cflag |= ~CS8;
tcsetattr(fd, TCSANOW, &options);
printf(“fin de la configuration\n”);
/if(code == “1222”)
printf(“code bon\n”);
else
printf(“code pas bon\n”);/
printf(“envoie des données\n”);
if(write(fd,&nombre, 1)<0 )
printf(“erreur”);
printf(“fin de l’envoie\n”);
fcntl(fd,F_SETFL,8);
reception=read(fd,&buffer,100);
printf(“nb de caracteres lu: %s\n”,reception,buffer);
if(reception==-1)
printf(“erreur lecture port \n”);
printf(“fin de la réception”);
}
close(fd);
}
But if i connect or not the IHM i have always the message “problème port serie” .
How i can solve this problem ? i need to change COM13 by the port COM of the USB host? what is the number for the usb host?
Thank you
Valentin