#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <termios.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <errno.h>
/************* VARS ***************/
static int fd;
static struct termios oldtio;
int main(int argc,char * argv[])
{
int ret;
int i;
if (argc!=2){
printf ("error no args..%d\n",argc);
return 1;
}
printf ("port: %s\n",argv[1]);
fd = open(argv[1], O_RDWR | O_NOCTTY);
if (!fd) {
printf("terminal is not open!\n");
return 1;
}
/* save current port settings */
ret = tcgetattr(fd, &oldtio);
if (ret < 0) {
printf("failed to get old attribs\n");
ret= 1;
goto quit;
}
ret = 0;
printf ("c_iflag = 0x%04X\n",oldtio.c_iflag);
printf ("c_oflag = 0x%04X\n",oldtio.c_oflag);
printf ("c_cflag = 0x%04X\n",oldtio.c_cflag);
printf ("c_lflag = 0x%04X\n",oldtio.c_lflag);
printf ("c_line = 0x%02X\n",oldtio.c_line);
printf ("c_ispeed = 0x%04X\n",oldtio.c_ispeed);
printf ("c_ospeed = 0x%04X\n",oldtio.c_ospeed);
for (i=0;i<NCCS;i++){
printf(" c_cc[%d]=0x%02X\n",i,oldtio.c_cc[i]);
}
quit:
close(fd);
return ret;
}
Comparing the vals with /usr/include/bits/termios.h, it was educational to first use minicom to communicate with even parity bit, then try the same with my pserial mods.. Initially found few flag setting issues, later found a fundamental error in my assumption in s_close function -> i assumed that it will happen at the end of transmission, in the case of a pci serial port, this would be true, but in the case of a usb2serial convertor, it looks like the data is send to the device but not actually transmitted on the lines :(.. a delay solved the issue..
bah!!! something silly!!! anyways, the patches are pushed to mainline omap-uboot-utils now.. you can get the source here . Will tag and make a binary zip for upload here a week from now if folks could let me know if things are working fine.... Meanwhile, I will try and create an beagle nand recovery tool updater later tonight.. just a bunch of wgets and ucmds I assume..
1 comment:
[BUG Warn]: 2008-12-04: 10:00 PM: as mentioned here I seem to have issues with usb2serial converters now - just after the PC has come up. I am guessing I am missing more flags.. but the work around is to openup minicom once -> things seem to work fine after that!! drat!!
Post a Comment