[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:
-
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();
}