Problem with 2406B to send file from my PC to FTP server


#1

[size=200]
Dear everyone:
I used Wavecome 2406B Modem to send .jpeg file from my PC to FTP sever which has a definite IP address, After input several AT commands for FTP transfer, 2406B GPRS modem shows "waitting for data"and FTPTYPE is already set to “I”, then I used my Visual C++ Program send binary data of my jpg file into serial port COM1, but problem occur, when the GPRS Modem came across binary data “00000011” which means “CTRL-C / ETX” in ASCii Code,the transfer was automatically stopped, while I still have a lot of data to send.
My question is: must I insert DLE before “00000011”,or the form of data I send into COM1 is not bnary data at all?
plus:

  1. I used MSComm to program COM1, and already set Setputmode(1),which means bianary data.
    2.my read file code:[/size]{
    CFile fp;
    BYTE writeBuffer[409600];

    fp.Open(“D:\test\map.txt”, CFile::modeRead|CFile::typeBinary);
    unsigned long fplength=fp.GetLength();

    fp.Read(writeBuffer,fplength);

    CByteArray sendArr;
    sendArr.RemoveAll();
    sendArr.SetSize(fplength);
    for(unsigned long i=0;i<fplength;i++)
    {
    sendArr.SetAt(i, writeBuffer[i]);
    }
    m_mscom.SetOutput(COleVariant(sendArr));
    fp.Close();
    }

=============================================

=============================================
adding “DLE” version:

void CSerial1Dlg::OnFileButton()
{

unsigned long k=0;
BYTE ETX=3;
BYTE DLE=16;
CFile fp;
BYTE writeBuffer[409600];
fp.Open("D:\\test\\testmap.jpg", CFile::modeReadWrite|CFile::typeBinary);
unsigned long fplength=fp.GetLength();
fp.Read(writeBuffer,fplength);

CByteArray sendArr;
sendArr.RemoveAll();
sendArr.SetSize(2*fplength);
for(unsigned long i=0;i<fplength+1;i++)
{
	
	if(i!=fplength)
	{
	if(writeBuffer[i]==ETX||writeBuffer[i]==DLE)
	{ 
	  sendArr.SetAt(i+k, DLE); 
       k++;
	}
	
	sendArr.SetAt(i+k, writeBuffer[i]);
	}
	else
		sendArr.SetAt(i+k, ETX);
    	
}
m_mscom.SetOutput(COleVariant(sendArr));
fp.Close();

}


#2

Hi,

The answer is “Yes”

You must insert DLE before each ETX character


#3

One more, any ETX character w/o DLE preceeding is used to tell the TCP/IP lib “end of transfer” and so connection will be terminated.


#4

Just for reference, this technique is sometimes known as “Byte Stuffing

The DLE is also sometimes known as an “escape” code, much like you use the backslash in ‘C’ for “escape sequences” like \n, \t, etc…


#5

[color=blue][size=150]I modified my sending file program, as I’ve already inserted DLE before every ETX except the last one which means the real end of the file.

But one more problem is : when the File which I gonna send is larger than 3K(but not always 4K, sometimes is 3K or 2K), the transfer cannot automatically
stopped,so I need input “CTRL-C” manually to end the transmit, and when I log on the FTP server to check if the file was correctlly transfered,I find it was not.
But while sending small files (normally smaller than 2K), it can automatically stopped, and the file is correctly transfered to the FTP server .

Can someone give me advices to solve this problem?
Thanks! [/size]


#6

The first thing you need to determine is whether this is a problem on your VC program that’s sending the data, or the embedded application in the modem.

Use the VC debugger to determine what is happening in your VC program when it gets past 3K…

Can you test your VC program with some other FTP server?