Is there a good way of debugging code that uses the Xmodem transfers? #29
-
Hi, Anyways, I got to the point where the transfers seemed to be working, but the final output was all 0xFFs. Clearly something's wrong, and I wish I could use Serial.println to get an idea of what's going on. Of course the Serial port on the arduino is busy with the Xmodem transfer. If I hit cancel in Tera Term, the Arduino seems to just reset. (maybe that's part of the problem?) Is there an easy way to debug things while an Xmodem transfer is active? How did you debug your Xmodem code? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Ron, I did most of the debugging by just storing a string that could be printed after the transfer finished. That's what the CmdStatus code does. Some additional variables were added later that are printed with the INFO command. See PromDevice.h and cpp for the debugXXX variables. You can do a lot with this approach: store packet numbers to see how far you are getting, store the first character of the packet, etc. You can even store one or more debug strings and print them later. Maybe build a small buffer, like 16 characters, and add code that copies the beginning bytes of the packet to it when sequencenumber==1. Then you can dump this after the transfer and compare it to the start of your file. If you really need live output, define a second serial port using the SoftwareSerial library and get a TTL to USB serial adapter to hook it up. You will need to turn the port speeds of your XModem port way down so that the debug port has enough time to keep up. I suspect you can do all of the debugging you need by just storing variables though. If Teraterm shows that the transfers are proceeding then that means your code is seeing the data from the host well enough to pull out the packet numbers and checksums to form its response. That would seem to indicate that the problem is either the code that is copying the data out of the packets or the code further down the line that is sending it out. Good luck with your project. Let me know if you need any additional information. |
Beta Was this translation helpful? Give feedback.
Ron,
I did most of the debugging by just storing a string that could be printed after the transfer finished. That's what the CmdStatus code does.
Some additional variables were added later that are printed with the INFO command. See PromDevice.h and cpp for the debugXXX variables. You can do a lot with this approach: store packet numbers to see how far you are getting, store the first character of the packet, etc. You can even store one or more debug strings and print them later. Maybe build a small buffer, like 16 characters, and add code that copies the beginning bytes of the packet to it when sequencenumber==1. Then you can dump this after the transfer and compare it to the start of yo…