11

I'm trying to send files over a COM port, but failed every time.

First, I configure a serial on each machine like this:

MODE COMx:115200,N,8

where x is the COM port number.

After this I'm trying to do:

COPY file.zip COM1: /B

and the reverse on the receiving PC.

In most cases I've gotten a broken archive. But last tries gave me nothing at all - first PC says that the file was sent, but the second is just waiting for data. Is there somebody who knows how to solve this?

4
  • Has this ever worked using this serial cable? Are you sure that you have a properly configured serial cable?
    – lit
    Apr 6, 2016 at 12:27
  • Cable works well, checked by sending with c# SerialPort class. And yes - i did this before - file was transfered well, but this works only with text files. Maybe binary copy flag will help with other files.
    – Alex
    Apr 6, 2016 at 12:49
  • Did you send non-text through the C## exercise? Of course, if the binary data includes a Control-Z (0x1A), then it would probably terminate the transfer.
    – lit
    Apr 6, 2016 at 14:30
  • You didn't mention what command you run on the receiving PC. COPY COM1: file.zip /B does not work. Receiver should enable IRQ on interrupt controller and on USART, receive data by interrupt handler, store them on disk. OS shell does not provide all theese chores.
    – vitsoft
    Apr 6, 2016 at 15:53

2 Answers 2

16

This works for me to send a binary file to an Arduino :

mode COM21 BAUD=115200 PARITY=n DATA=8
copy yourfile.txt \\.\COM21

Notice the \\.\ which is mandatory for port numbers >= 10, and can be used too for port numbers 1-9.

6
  • 1
    How would you copy that file in /home/ directory of COM21?
    – Sedmaister
    Jan 4, 2019 at 20:55
  • I'm not sure to understand your question because the serial protocol (rs-232) used for COM ports only defines how to send and receive bytes to/from a serial device, it doesn't define anything about a file system (in particular it doesn't define a home directory). Most serial devices, for example a serial mouse or a serial modem don't have any file system. You can find more information about rs-232 here : en.wikipedia.org/wiki/RS-232#Sp%C3%A9cification
    – Ben
    Jan 4, 2019 at 21:26
  • Thanks @Ben, let me clarify my question: Is it possible to transfer files into a linux file system (such as ext2) over COM port? If yes, how would the command look like from windows shell?
    – Sedmaister
    Jan 7, 2019 at 18:01
  • 5
    The short answer would be no, the RS-232 protocol is very low level : send bytes, receive bytes, without any interpretation. Linux wouldn't even know when is the start and the end of the file transmitted, or its file name. But what you're looking for is probably Kermit ( en.wikipedia.org/wiki/Kermit_(protocol) ) or Zmodem. There are softwares that implement it for Windows and for Linux, with this it should be possible to transfer files over a serial line. There's an howto here : andym3.wordpress.com/…
    – Ben
    Jan 17, 2019 at 19:14
  • 1
    It depends on your destination, the serial protocol just sends the bytes of the file to the COM port. For example you can send a file to a serial mouse, which will not do anything with this information, and will not save it as a file (and you will however see that the transfer was successful because there's no check at all in the protocol). But if you send it to another Windows computer, where a specific software is "listening" to that specific serial port, then you can recover the file and save it where you want. An example of such a software is Kermit : kermitproject.org/k95.html
    – Ben
    Apr 22, 2021 at 7:50
3

You need to specify /B for binary file after the .zip file (or whatever else it is) as well as at the end of the command line. e.g. COPY ABinary.File /B COM1 /B otherwise it will stop at the first non-text ASCII character.

Try using Hyperterminal at the receiving end and Transfer > Capture Text

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.