int size;
int *i,j,k;
QFile file("/sfiles/mxdrv.tgz");
if(!file.open( IO_ReadOnly ))
{
QMessageBox::information(0,
"Error",
"Error opening file");
}
else
{
cout<<"File opened successfully"<<endl;
}
cout<<"file opened...."<<endl;
unsigned char fname[]="mxdrv.tgz";
struct termios t;
char *device = "/dev/ttyS0";
int sPort, rbyte, status, sPortdest,length;
long count=0;
unsigned char send1[32];
t.c_cc[VMIN] = 1;
t.c_cc[VTIME]=0;
t.c_cc[VEOF]='\n';
t.c_iflag |= (ISIG);
t.c_iflag &= ~BRKINT;
t.c_cflag = B9600 | CS8 | CREAD | CLOCAL | HUPCL;
sPort = open(device,O_RDWR|O_NOCTTY|O_NDELAY);
if(sPort != -1)
{
cout<<"open successfully\n";
status = ioctl(sPort,TCSETS,&t);
cout<<"Entering status"<<status<<endl;
if(status==0)
{
//for(count=0;count<20;count++)
cout<<"sending name"<<endl;
rbyte=write(sPort,fname,strlen((char *)send1));
//usleep(3000);
cout<<"name sent"<<endl;
cout<<"now sending file"<<endl;
while(!file.atEnd())
{
//cout<<"Enter :";
//cin>>send1;
//strcat((char *)send1,"{MSS TYPE-D DAMA}");
// write(sPort,"{012345678}",11);
*i=file.getch();
rbyte=write(sPort,i,sizeof(*i));
cout<<rbyte<<"sent"<<endl;
//cout<<"w b:"<<rbyte<<"\t Time:"<<count<<"\t string:"<<send1<<"\n";
//usleep(1000);
}
}
close(sPort);
}
else
{
cout<<"Device could not be opened";
}
file.close();
int size;
int *i,j,k;
QFile file("/sfiles/mxdrv.tgz");
if(!file.open( IO_ReadOnly ))
{
QMessageBox::information(0,"Error","Error opening file");
}
else
{
cout<<"File opened successfully"<<endl;
}
cout<<"file opened...."<<endl;
unsigned char fname[]="mxdrv.tgz";
struct termios t;
char *device = "/dev/ttyS0";
int sPort, rbyte, status, sPortdest,length;
long count=0;
unsigned char send1[32];
t.c_cc[VMIN] = 1;
t.c_cc[VTIME]=0;
t.c_cc[VEOF]='\n';
t.c_iflag |= (ISIG);
t.c_iflag &= ~BRKINT;
t.c_cflag = B9600 | CS8 | CREAD | CLOCAL | HUPCL;
sPort = open(device,O_RDWR|O_NOCTTY|O_NDELAY);
if(sPort != -1)
{
cout<<"open successfully\n";
status = ioctl(sPort,TCSETS,&t);
cout<<"Entering status"<<status<<endl;
if(status==0)
{
//for(count=0;count<20;count++)
cout<<"sending name"<<endl;
rbyte=write(sPort,fname,strlen((char *)send1));
//usleep(3000);
cout<<"name sent"<<endl;
cout<<"now sending file"<<endl;
while(!file.atEnd())
{
//cout<<"Enter :";
//cin>>send1;
//strcat((char *)send1,"{MSS TYPE-D DAMA}");
// write(sPort,"{012345678}",11);
*i=file.getch();
rbyte=write(sPort,i,sizeof(*i));
cout<<rbyte<<"sent"<<endl;
//cout<<"w b:"<<rbyte<<"\t Time:"<<count<<"\t string:"<<send1<<"\n";
//usleep(1000);
}
}
close(sPort);
}
else
{
cout<<"Device could not be opened";
}
file.close();
To copy to clipboard, switch view to plain text mode
Bookmarks