• Support
  • Articles
  • Resources
  • Products

why the first xmodem packet been always send out twice?

Moderator: boris

7 postsPage 1 of 1

darthcheng
Newbie

Posts:
7
Joined: Mon Sep 18, 2006 1:10 pm
by darthcheng » Tue Sep 26, 2006 9:17 am
Hi,

I'm using the xmodem-CRC sending function of TeraTerm 4.45 to send out my program file for AVR now and I'm also using a serial port monitor program to check the data traffic in the serial interface between PC and my AVR. I found out that TeraTerm will always send out the first xmodem-CRC packet twice before it receive any response from my AVR, but it should wait for ACK or NACK after sending out the first packet just once. So why???

 

Trevor
Guru

Posts:
485
Joined: Wed Jul 26, 2006 8:47 am
by Trevor » Mon Feb 05, 2007 2:21 pm
I'm pretty sure this is related to this

 

darthcheng
Newbie

Posts:
7
Joined: Mon Sep 18, 2006 1:10 pm
by darthcheng » Sat Mar 03, 2007 11:04 am
Hi,

I just tried the new TT4.5. But it's the same result for my microprocessor.
The first packet been sent twice.

In my code of microprocessor, after it starts to wait for the XMODEM-CRC packet, it will send out C to PC every 1 second, and the same time, I will select the file I want to send to my microprocessor. My PC is fast enough (HP DV9072ea), so is 1 second too short for TT??
ilya
Newbie

Posts:
3
Joined: Fri Aug 26, 2011 2:08 pm
by ilya » Fri Aug 26, 2011 2:32 pm
I'm using TeraTerm 4.70, the same issue (duplicated first packet). I'm using Xmodem-CRC, standard 128-byte packets. Receiver initiates transmission with "c" (CRC mode). The same receiver works fine with HyperTerminal. I know that this is wrong receiver behaviour which must discard duplicated packets, but unfortunately I can't change it.
Here is the capture from HHD for teraterm:



And here is the capture for HyperTerm:
ilya
Newbie

Posts:
3
Joined: Fri Aug 26, 2011 2:08 pm
by ilya » Fri Aug 26, 2011 7:18 pm
I think I know what the problem is.
Many receivers (and my device in particular) send "C" periodically (every second in my case). Teraterm stops getting data from com port into internal buffer when the user goes to the menu, CommReceive() is not called anymore. However before this happens, one "C" caracter is read into the input buffer and not consumed (not echoed into terminal). I don't know how exactly this happens. The rest of "C" characters is accumulated in COM port buffer while user selects file.

When transmission starts, input buffer is not flushed. Now if we check the file teraterm/ttpfile/xmodem.c, function XSendPacket(), we can see that this "C" character from internal buffer will trigger transmission of first packet. XSendPacket() also tries to consume all extra characters from internal buffer, but as I said before, there was only one there. After that CommReceive() function is finally called, and all "C" caracters accumulated in COM port buffer are read into internal rx buffer. So when XSendPacket() is called for the second time, it finds another "C" character which triggers packet re-send. The rest of "C" characters in internal buffer is flushed.

Possible solutions:
1. Flush input buffer when XModem starts
2. Consume all data from input buffer leaving only the last character, before doing the rest of XSendPacket()
3. ignore all "C" characters after the first packet was sent
4. Call CommReceive() at some point before calling XSendPacket() for the first time.
5. something else..

I've chosen variant 3 because it was easiest for me. But I don't think this is the best solution, because other protocols could also be affected in similar way. Variant 4 looks better, but I'm not familiar with the code to chose the best place to call CommReceive().

Here is my solution:


This works perfectly for me.
Cheers!
Yutaka Hirata
TeraTerm Developer

Posts:
609
Joined: Wed Jan 12, 2005 2:35 pm
by Yutaka Hirata » Sun Aug 28, 2011 12:29 pm
Hi ilya,

Thank you for your patch.
I will commit your code to the trunk repository for 4.72 release because
Tera Term 4.71 will be released soon.
Best regards, Yutaka Hirata
(yutakakn at gmail.com)
http://hp.vector.co.jp/authors/VA013320/
Yutaka Hirata
TeraTerm Developer

Posts:
609
Joined: Wed Jan 12, 2005 2:35 pm
by Yutaka Hirata » Wed Aug 31, 2011 2:19 pm
Hi everyone,

I have committed ilya-san patch to the repository and uploaded
the latest archive in the following site:

http://ttssh2.sourceforge.jp/snapshot/s ... 110831.zip
Best regards, Yutaka Hirata
(yutakakn at gmail.com)
http://hp.vector.co.jp/authors/VA013320/
Display posts from previous:
Sort by:

7 postsPage 1 of 1

Users browsing this forum: No registered users