Getting NAK after AT+CFUN=1 after XMODEM1k

Hi, I have written my own production app for flashing the .dwl file to the modem. The xmodem process completes as expected (i.e. I get an ACK for each packet including the final EOT). I then immediately send AT+CFUN=1, but then when the modem restarts I keep getting NAK’s until I send an AT command.

Any ideas? The modem is then in a funny state and I need to restart for normal AT commands to work.

I have put a serial port monitor on the system and compared it to what Developer studio does, and it looks the same. I am a bit baffled.

Below is the end of the transmission

TX

E1 0C 81 5D 2E 51 4E A8 24 54 11 14 42 0D A1 9E
 D0 40 68 22 B4 12 FC 84 0E 42 27 A1 87 D0 4F 18
 26 8C 10 46 09 3B 08 3B 09 63 84 71 C2 5E C2 7E
 C2 21 C2 61 C2 11 C2 31 C2 71 C2 49 C2 29 C2 19
 02 9B 25 51 4E 90 36 CD 34 66 B7 37 AC 70 D4 2B
 E2 7F C2 5A A6 D8 ED AB EA 6F C9 7A 96 6C D3 83
 7B E6 FD 1F 50 FC 01 80 00 00 00 1A 1A 1A 1A 1A
 1A 1A 1A 1A 1A 1A 1A 1A 1A 1A 1A 1A 1A 1A 1A 1A
 1A 1A 1A 1A 1A 1A 1A 1A 1A 1A 1A 1A 1A 1A 1A 1A
 1A 1A 1A 1A 1A 1A 1A 1A 1A 1A 1A 1A 1A 1A 1A 1A
 1A 1A 1A 29á.].QN¨$T..B.¡ž
Ð@h"´.ü„.B'¡‡ÐO.
&Œ.F.;.;.c„qÂ^Â~
Â!ÂaÂ.Â1ÂqÂIÂ)Â.
.›%QN6Í4f·7¬pÔ+
âÂZ¦Øí«êoÉz–lÓƒ
{æý.Pü.€........
................
................
................
...)
4284089: 11.10.2013 12:36:43.586 +0.0

 04                                                .

4284101: 11.10.2013 12:36:44.647 +0.0

 41 54 2B 43 46 55 4E 3D 31 0D                     AT+CFUN=1.

4284116: 11.10.2013 12:36:44.647 +0.0



4284565: 11.10.2013 12:37:34.648 +0.0

RX

4284080: 11.10.2013 12:36:43.571 +0.0

 06                                                .
4284092: 11.10.2013 12:36:44.647 +1.060

 06                                                .
4284182: 11.10.2013 12:36:54.914 +0.109

 15                                                .
4284190: 11.10.2013 12:36:55.414 +0.499

 15                                                .
4284198: 11.10.2013 12:36:56.412 +0.998

 15                                                .
4284206: 11.10.2013 12:36:57.410 +0.998

Your help would be appreciated…

Thanks,

Karl

Can you try to send AT+CFUN=1 after you received first few NAK (0x15)?

Hi Lotam, thank you for your reply. I have now managed to get this to work. The problem was really around the criticality of timing and the fact that USB management in Windows is not great. So what was happening was that the module resets and this causes the USB port to disconnected from the PC and then added again. USB <-> serial architecture in windows does not allow for graceful closure of the port which result in exceptions whenever you try to do something on that port. Even if you try and close the port. So if you are in this scenario, you can’t even remove the ports resources and then recreate one. Windows throws it toys out of the cot… So one needs to make sure one closes the port before this happens.

This is what I was doing. I sent the AT+CFUN=1 out the port and then immediately closed it. I even checked if the bytes had been sent (as far as the port was concerned). But what was happening here, is that the port was closing and shutting down the USB drivers etc before the data was actually sent out the FIFO buffers (even though the .Net SerialPort class thought the data had been sent). So now by waiting 50ms after sending AT+CFUN=1 I can be sure the data has actually been sent. Then shut the port and I had to monitor DeviceNotification messages to find out when the USB had been re-attached. I can then only open the Serial port again and with this I have a working flasher :slight_smile:

Thanks for you interest. I have listed the above for anyone else that might be trying to do this.

Thanks,

Karl