0

I'm trying to send files over a half-duplex interface (RS-485) between a box PC running debian (4.19) and a SBC with an im6xDL.

Thanks to this community I can successfully transfer simple data between the units using picocom or by echoing/reading.

The box PC supports half-duplex RS-485 natively and has automatic RTS functions so that you can read/send data without any issue. The SBC on the other hand needs to be toggled to change into RX or TX mode.

This turned out to be a problem when I tried to send files from the box PC to the SBC.

On the box PC:
picocom /dev/ttyUSB0 -b 9600 -fn
C-a,C-S
***file: /home/user/test.txt
Transfer incomplete

*** exit status: 128

On the SBC
picocom /dev/ttymxc2 -b 9600 -fn -et
C-a,C-r
Terminal ready
�000000

As you can see something is terribly wrong, it is like it cannot interpret the bits when a file is being transferred.

My questions:

  1. Is it possible to send files from the command line in half-duplex systems? (The SBC needs to be in RX mode the entire time).

  2. Is there another way to achieve this that is more intuitive?

As always, thanks for the help and support :)

/W

wild_w
  • 67
  • 1
  • 1
  • 6
  • there may be more knowledge about this on https://raspberrypi.stackexchange.com ., but please don't cross-post (one or the other ;-)! Good luck! – shellter May 30 '19 at 12:13

1 Answers1

0

See here:

Pymodbus - Read input register of Energy meter over rs485 on uart of raspberry pi3

The solution I presented there using pylibmodbus should work for any hardware with UART and one or two GPIO lines accessible from user space in Linux.

If, on the other hand, what you want to do is use something like picocom or minicom then you can take a look at the hardware-only solution using a 555 timer.

Of course, if prototyping circuits is not for you, you can always buy a USB to RS485 with half-duplex support. You have many available but those based on the MAX13487 IC seem to work very well.

EDIT: The solution using the 555 timer is not in the post I linked above but here together with some more background material on half-duplex RS485 links: RS485: Inappropriate ioctl for device

Marcos G.
  • 3,371
  • 2
  • 8
  • 16
  • Sorry for a late response Marcos. I ended up changing the hardware for this demo to something that supported the automatic transmit. Got the idea from your 555 timer example(or rather learned it :-)). I will probably come back to your pymodbus example once I'm going to start on this project. Thanks again for your help! – wild_w Jun 03 '19 at 11:56
  • good to hear you have it working. It's always easier when you have the half-duplex in hardware but pylibmodbus is quite reliable if you don't – Marcos G. Jun 03 '19 at 16:15
  • Hello Marcos, I'm now starting on the real project and I have been reading up on modbus. I will need to send files ~10-20MB and the general idea on forums is that modbus is not a good way to achieve this? I have been looking into using QT with libraries for RS-485, do you have any thoughts? – wild_w Jun 12 '19 at 15:04
  • Hello Willie, I don't think Modbus is a good choice to send that much data. But you don't think to use it, if you have two computers you can send files via a terminal encoded in ASCII or binary. Maybe it's better if you write a new question elaborating a bit more what exactly you want to do, ok? – Marcos G. Jun 12 '19 at 15:58