here's wat i have done

Qt Code :

Qt Code:
  1. int size;
  2. int *i,j,k;
  3. QFile file("/sfiles/mxdrv.tgz");
  4. if(!file.open( IO_ReadOnly ))
  5. {
  6. QMessageBox::information(0,"Error","Error opening file");
  7. }
  8. else
  9. {
  10. cout<<"File opened successfully"<<endl;
  11. }
  12. cout<<"file opened...."<<endl;
  13. unsigned char fname[]="mxdrv.tgz";
  14.  
  15. struct termios t;
  16. char *device = "/dev/ttyS0";
  17.  
  18. int sPort, rbyte, status, sPortdest,length;
  19. long count=0;
  20.  
  21. unsigned char send1[32];
  22.  
  23.  
  24. t.c_cc[VMIN] = 1;
  25. t.c_cc[VTIME]=0;
  26. t.c_cc[VEOF]='\n';
  27.  
  28. t.c_iflag |= (ISIG);
  29. t.c_iflag &= ~BRKINT;
  30. t.c_cflag = B9600 | CS8 | CREAD | CLOCAL | HUPCL;
  31.  
  32. sPort = open(device,O_RDWR|O_NOCTTY|O_NDELAY);
  33.  
  34. if(sPort != -1)
  35. {
  36. cout<<"open successfully\n";
  37.  
  38. status = ioctl(sPort,TCSETS,&t);
  39. cout<<"Entering status"<<status<<endl;
  40. if(status==0)
  41. {
  42.  
  43. //for(count=0;count<20;count++)
  44. cout<<"sending name"<<endl;
  45. rbyte=write(sPort,fname,strlen((char *)send1));
  46. //usleep(3000);
  47. cout<<"name sent"<<endl;
  48. cout<<"now sending file"<<endl;
  49. while(!file.atEnd())
  50.  
  51. {
  52. //cout<<"Enter :";
  53. //cin>>send1;
  54. //strcat((char *)send1,"{MSS TYPE-D DAMA}");
  55. // write(sPort,"{012345678}",11);
  56. *i=file.getch();
  57. rbyte=write(sPort,i,sizeof(*i));
  58. cout<<rbyte<<"sent"<<endl;
  59. //cout<<"w b:"<<rbyte<<"\t Time:"<<count<<"\t string:"<<send1<<"\n";
  60. //usleep(1000);
  61.  
  62. }
  63.  
  64. }
  65. close(sPort);
  66.  
  67. }
  68. else
  69. {
  70. cout<<"Device could not be opened";
  71. }
  72. file.close();
To copy to clipboard, switch view to plain text mode 


by running this code from the shell, following is the output :

File opened successfully
file opened....
open successfully
Entering status0
sending name
name sent
now sending file
Segmentation fault


can any1 please tell watz going wrong over here ??