Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to send file over serial port in Windows Command Prompt

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?

like image 437
James Jason Avatar asked Apr 06 '16 06:04

James Jason


People also ask

How do you transfer data to a serial port?

To transmit a data byte, the serial device driver program sends a data to the serial port I/O address. This data gets into a 1-byte "transmit shift register" in the serial port. From this shift register bits are taken from the data one-by-one byte and sent out bit-by-bit on the serial line.

How do I open a port in CMD?

#1) Right-click on the start menu. #2) Select Command Prompt (Admin). #3) Type 'netsh firewall show state; or Netstat -ab. #4) Hit Enter.

How do I connect to a serial port in Windows?

Open a console sessionUsing PuTTY or other terminal emulator, select "Serial" as the connection type and change the "Serial line" to match the COM port noted earlier. The serial console speed is typically 9600. Click "Open" to connect to the console.


2 Answers

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.

like image 55
Ben Avatar answered Oct 11 '22 13:10

Ben


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

like image 32
James Avatar answered Oct 11 '22 13:10

James