Need help with using MOXA 1110 USB to serial device to connect to RS232 port on weighbridge

raspberrypi3

#1

Hi, my USB to Serial Moxa UPORT 1110 device is not recognised by my resin deployment.

Assuming I can get a compiled binary, I need to understand how to set up the git repo to ensure that the module loads on all my devices.

Output of dmesg is posted below:

[ 351.024882] usb 1-1.4: new full-speed USB device number 8 using dwc_otg
[ 351.198542] usb 1-1.4: New USB device found, idVendor=110a, idProduct=1110
[ 351.198567] usb 1-1.4: New USB device strings: Mfr=1, Product=2, SerialNumber=0
[ 351.198580] usb 1-1.4: Product: UPort 1110
[ 351.198591] usb 1-1.4: Manufacturer: Moxa Technologies Co., Ltd.
[ 351.222251] usbcore: registered new interface driver usbserial
[ 351.222361] usbcore: registered new interface driver usbserial_generic
[ 351.222452] usbserial: USB Serial support registered for generic
[ 351.239142] usbcore: registered new interface driver ti_usb_3410_5052
[ 351.239272] usbserial: USB Serial support registered for TI USB 3410 1 port adapter
[ 351.239363] usbserial: USB Serial support registered for TI USB 5052 2 port adapter
[ 351.239501] ti_usb_3410_5052 1-1.4:1.0: TI USB 3410 1 port adapter converter detected
[ 351.239779] usb 1-1.4: Direct firmware load for moxa/moxa-1110.fw failed with error -2
[ 351.239799] usb 1-1.4: ti_download_firmware - firmware not found
[ 351.239848] ti_usb_3410_5052: probe of 1-1.4:1.0 failed with error -5

#5

@surekap Can you post the Dockerfile for your app please?


#6

$ cat Dockerfile.template

FROM resin/%%RESIN_MACHINE_NAME%%-node:6

# Install other apt deps
RUN apt-get update && apt-get install -y \
  apt-utils \
  clang \
  xserver-xorg-core \
  xserver-xorg-input-all \
  xserver-xorg-video-fbdev \
  xorg \
  libdbus-1-dev \
  libgtk2.0-dev \
  libnotify-dev \
  libgnome-keyring-dev \
  libgconf2-dev \
  libasound2-dev \
  libcap-dev \
  libcups2-dev \
  libxtst-dev \
  libxss1 \
  libnss3-dev \
  fluxbox \
  libsmbclient \
  libssh-4 \
  fbset \
  libexpat-dev && rm -rf /var/lib/apt/lists/*

# Set Xorg and FLUXBOX preferences
RUN mkdir ~/.fluxbox
RUN echo "xset s off" > ~/.fluxbox/startup && echo "xserver-command=X -s 0 dpms" >> ~/.fluxbox/startup
RUN echo "#!/bin/bash" > /etc/X11/xinit/xserverrc \
  && echo "" >> /etc/X11/xinit/xserverrc \
  && echo 'exec /usr/bin/X -s 0 dpms -nolisten tcp "$@"' >> /etc/X11/xinit/xserverrc

# Move to app dir
WORKDIR /usr/src/app

# Move package.json to filesystem
COPY ./app/package.json ./

# Install npm modules for the application
RUN JOBS=MAX npm install --unsafe-perm --production \
	&& npm cache clean && node_modules/.bin/electron-rebuild

# Move app to filesystem
COPY ./app ./

## uncomment if you want systemd
ENV INITSYSTEM on

# Start app
CMD ["bash", "/usr/src/app/start.sh"]

Output of start.sh

$ cat app/start.sh

#!/bin/bash

# By default docker gives us 64MB of shared memory size but to display heavy
# pages we need more.
umount /dev/shm && mount -t tmpfs shm /dev/shm

# start the flask server
get_pip() {
	if hash pip 2>/dev/null; then
		echo "Found pip. Skipping install."
	else
		if [ ! -f get-pip.py ]; then
			wget https://bootstrap.pypa.io/get-pip.py
		fi
		python get-pip.py
	fi
}

get_pip
/usr/local/bin/pip install -U flask
/usr/local/bin/pip install -U flask-cors
/usr/local/bin/pip install -U pyserial
python /usr/src/app/escpos/app.py &

# using local electron module instead of the global electron lets you
# easily control specific version dependency between your app and electron itself.
# the syntax below starts an X istance with ONLY our electronJS fired up,
# it saves you a LOT of resources avoiding full-desktops envs

rm /tmp/.X0-lock &>/dev/null || true
startx /usr/src/app/node_modules/electron/dist/electron /usr/src/app --enable-logging

I realize that I am using an old build - I would be happy to upgrade but I couldn’t get electron and python to work together. The python app.py runs a simple flask server on localhost:80 which writes raw bytes to a barcode printer (/dev/usb/lp0) and a weighbridge connected to the usb port via RS232-USB cable (which I can’t get to work).

I emailed MOXA for a driver but they said the raspberry pi is not supported. So I tried with a different cable. This one uses the TI 3410 driver which is also not found - same error - devices shows up in lsusb -v and lsmod but there is no /dev/ttyUSB0 or anything.


#8

@surekap, looking at the dmesg output, I think you’re right that you don’t have a driver for this device. You can load device drivers inside your application container using insmod or modprobe but you would need to have an appropriate driver.

If the Raspberry Pi isn’t supported by the device manufacturer there’s probably not a lot we can do. The driver would need to be built for the ARM architecture to work there.

Do you know if there is a supported driver for your TI cable? If so you should be able to load it inside your image.


#9

I found some fw files

https://github.com/adafruit/rpi-firmware/blob/master/firmware/ti_3410.fw

root@aad8a1b:/usr/src/app# wget https://github.com/TI-OpenLink/firmwares/raw/master/ti_3410.fw
… snipped …
root@aad8a1b:/usr/src/app# insmod ti_3410.fw
insmod: ERROR: could not insert module ti_3410.fw: Invalid module format
root@aad8a1b:/usr/src/app# modprobe ti_3410
modprobe: FATAL: Module ti_3410 not found.
root@aad8a1b:/usr/src/app# insmod ti_3410
insmod: ERROR: could not load module ti_3410: No such file or directory


#14

Ah, the firmware you found is a binary firmware blob rather than a kernel module (which would be a .ko file).

You might be able to try putting that file on /lib/firmware/moxa on the SD card (i.e. put it in your laptop and write to it there before booting your device).

I’ve also gotten some suggestions that https://github.com/wkennington/linux-firmware/blob/master/moxa/moxa-1110.fw might actually be the real firmware blob that you need here, so it might be worth giving that a shot. Unfortunately most of this is actually outside the scope of resin itself so we can only really give some pointers. (E.g. if the device is completely unsupported on the Pi there’s not much we can do to help get it running there in resin as we don’t have the drivers either.)


#16

One “outside chance” suggestion, that I don’t notice has cropped up yet, but does this peripheral work on raspbian, i.e. can we confirm that the peripheral is compatible with the Pi?


#18

Hi @mccollam,

You might be able to try putting that file on /lib/firmware/moxa on the SD card (i.e. put it in your laptop and write to it there before booting your device).

Can you please clarify where to put the .fw file - If I mount the sd card on windows or mac, all I see is a boot partition. Where does the .fw file go?

Alternatively, since my devices are already in the field, it would be quite painful to get the SD cards back and redo this. Is there some command I can run in my resin config or Dockerfile.template to do this in one shot for all devices…
e.g.

modprobe ti_usb_3410_5052 firmware_path=/usr/src/app/ti_3410.fw

#19

You’ll probably have to use a Linux system to see all the partitions on the SD card. It would be in the root partition that you need to add this.

Unfortunately there’s no easy way to load this remotely at the moment, and it’s still not guaranteed to work as it is. It’s unclear to me whether just the firmware will even be enough to make this device work; there is likely still a driver that will need to be loaded.

The best solution would be to find a device that is already supported under Linux on ARM and replace the device with that. There’s not a lot that we can do on the resin.io side. This is up to the device manufacturer – if it’s not supported on a Raspberry Pi at all it won’t work on a Raspberry Pi under resin.io either.


#25

Just thought I’d update this with my findings. I eventually solved the problem by using a different USB-Serial cable from a different provider with a different chipset. Worked just fine out of the box!