CMD - How To Send File Over Serial Port in Windows Command Prompt - Stack Overflow
CMD - How To Send File Over Serial Port in Windows Command Prompt - Stack Overflow
Prompt
Asked 8 years, 7 months ago Modified 2 months ago Viewed 89k times
I'm trying to send files over a COM port, but failed every time.
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?
Share Improve this question edited Sep 21, 2018 at 12:09 asked Apr 6, 2016 at 6:27
Follow Martin Valgur Alex
6,232 1 38 47 146 1 1 10
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
Notice the \\.\ which is mandatory for port numbers >= 10, and can be used too for port
numbers 1-9.
Share Improve this answer Follow edited Sep 24, 2016 at 10:44 answered Sep 24, 2016 at 7:05
Stephan Ben
56k 10 64 95 1,758 1 12 12
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
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
3 non-text ASCII character.
Try using Hyperterminal at the receiving end and Transfer > Capture Text
Share Improve this answer Follow edited Oct 8, 2018 at 12:13 answered Dec 16, 2016 at 11:23
Martin Valgur James
6,232 1 38 47 31 1