Hi,
I am using mangohred 7502 module. i am trying serial port program between host to target . I tried DM COM and all other com ports in terminal in windows. I am using max232 and voltage level shifter yf08E. I mapped uart to 17,1 and i used /dev/hs0 . i am posting the program below. in .adef file i added [rw] /dev/hs0 /dev/hs0 also. I am unable to read/write data from/to the terminal. please guide me to establish communication.
Thanks and regards,
K Subrahmaniam
#include “legato.h”
#include “interfaces.h”
#include <le_tty.h>
#include <unistd.h>
#include <string.h>
//void uartInit();
COMPONENT_INIT
{
le_result_t result;
char buffer[20]= “Hello\n”;
// int readSerial;
int i=0;
int len;
//printf(“hI”);
const char *serialport = “/dev/ttyHS0”;
int fd = le_tty_Open(serialport, O_RDWR|O_NDELAY|O_NOCTTY|O_NONBLOCK);
if(fd == -1)
{
//LE_FATAL("Error Opening %S err[%d]: %s", SERIAL_PORT,errno,strerror(errno));
LE_INFO("failed");
}
else
LE_INFO("SUCCESS opening");
LE_INFO("%d", fd);
le_tty_SetBaudRate(fd,13);
char parity = 'N';
le_tty_SetFraming(fd,parity,8,1);
result = le_tty_SetCanonical(fd);
if(result == LE_OK)
LE_INFO("canonical mode is set");
do
{
LE_INFO("Enter do while loop");
len = write(fd,buffer,6);
sleep(2);
LE_INFO("Number of bytes writen is %d",len);
// readSerial = read(fd,buffer,sizeof(buffer));
// LE_INFO("Read bytes are:%d",readSerial );
// LE_INFO(buffer);
i++;
/* if(readSerial > 0)
{
LE_INFO("Read bytes are:%d",readSerial );
for(i=0;i<readSerial;i++)
{
printf("%c",buffer[i]);
}printf("\n");
}
else
{
printf("error readSerial = %d\n",readSerial);
}*/
}while(1);
le_tty_Close(fd);
}