📜 ⬆️ ⬇️

Development of software for laser thickness on FriendlyARM Smart210

Short description: the task is to measure the cross section of an object between two moving laser sensors, the whole calculation takes place on the computer side.

Qt was chosen as a development tool due to the fact that it is a cross-platform product, as well as OpenSource. Qt was installed the latest at the time of version 5.4. The initial use of the program was assumed under Windows OS with a touch screen. Somewhere in the middle of the path we decided to remake the Smart210.

Smart210 development of our Chinese counterparts, with the ability to install operating systems (included): WinCE 6, Linux, Qtopia, Android. The Debian build was also tested.

The target system on this device was originally Linux. Working with the thickness gauge controller via FT2232HL.
')
The use of proprietary FTDI drivers has a number of steps and features:

Requires disabling the standard ftdi_sio and usbserial libraries:

sudo rmmod ftdi_sio sudo rmmod usbserial 

This is impossible to do without rebuilding the kernel with the inclusion of these libraries as kernel modules.

The kernel was built using the toolschain arm-linux- version 4.5.1 supplied by the manufacturer, an attempt to build the kernel with newer compilers caused the touchscreen to not work, because the module sarmarm-ts-mtinput (responsible for the multi touch screen) fell into errors, possibility of rebuilding for new compilers is missing (no source).

In the file mini210_linux_defconfig, set the path to the compiler and configure as kernel modules:

 CONFIG_CROSS_COMPILE="arm-linux-" ... CONFIG_USB_SERIAL=m CONFIG_USB_SERIAL_FTDI_SIO=m 

Although CONFIG_USB_SERIAL = m includes all dependent libraries as kernel modules, including ftdi_sio (just in case CONFIG_USB_SERIAL_FTDI_SIO = m). Then execute the command:

 ./build 

Since the composition of the modules has changed, it is necessary to perform:

 make modules 

After that, it remains to copy to the file system. Building the file system with the yaffs2 utility bundled from the disk caused a file error at the time of installation. I had to use the standard:

 mkyaffs2 rootfs_rtm_210 rootfs_rtm_210.img 

After the done manipulations it became possible to use the FTDI library.
Qt to work in Linux took version 5.3.2 and compiled with linuxfb support.

Subsequent use of this approach revealed insufficient drawing speed (the touch screen did not react when drawing). Used for drawing frame buffer, the lack of support for OpenGL ES from the drivers.

I stopped on Android, I had to redraw the rewrite to use ttyUSB, since FTDI driver for Android exists only for Java.

When FTDI was disconnected and connected, the appearance of 0x00 bytes was found, which led to a shift, and with a fixed data length of 10 bytes and without the sign of the beginning of the packet, it created trouble. In addition, a break (as an emergency could break a packet), the solution is to look for the first 10 bytes tested for CRC8:

 bool Controller::readBlockN(uchar *tmp, qint64 blockSize){ int bytesReceived = 0; int bytesRead = 0; qint64 m_blockSize = blockSize; while (m_blockSize > 0) { bytesReceived = read(uart0_filestream, ((void*)&tmp_block) + bytesRead, m_blockSize); if (bytesReceived > 0){ m_blockSize -= bytesReceived; bytesRead += bytesReceived; if (bytesRead > 9) { if (tmp_block[bytesRead - blockSize + 9] == getCRC8((uchar*)&tmp_block + bytesRead - blockSize, 9)){ memcpy(tmp, (uchar*)&tmp_block + bytesRead - blockSize, 10); } else{ m_blockSize = 1; } } } } return true; } 

At this stage, it was discovered that there are no rights to use ttyUSB * ports and this happens after each reboot. The solution is to insert a string when loading the program:

 system("su -c 'chmod 777 /dev/ttyUSB*'"); 

It remained to remove the navigation bar (make the most of the screen, in addition, it is assumed that this device will not run other applications). The standard panel does not respond to hiding events and is always on top of all applications. I decided to just remove it:

 system("su -c 'rm /system/app/SystemUI.apk'"); 

FriendlyARM has a battery that does not reset the time, but still decided to call the standard Android date settings when you start the application:

 system("am start -n com.android.settings/.DateTimeSettingsSetupWizard"); 


Graphics are fully traced in QgraphicsView:

System Status:



Manual mode:



Auto mode:



Video:



Surveys and results:

Debian:
Cumbersome, takes ~ 430MB in its pure form, there is support for OpenGL ES, the mesa driver is used. There is no support for multi touch screen.

Qtopia:
The lack of support for OpenGL ES, and she herself has not been supported for a long time.

Linux (rootfs_rtm_210):
The lack of support for OpenGL ES, takes up very little space in its pure form ~ 15MB, with all Qt ~ 90MB libraries installed, the OS download speed is just over 8 seconds.

WinCE 6:
Not tested seriously, just rummaged in a binary file on the mention of OpenGL ES, and it would require an argument under CE. Time is running out decided to postpone.

Android:
Supports OpenGL ES, takes ~ 215 MB, runs about 2 minutes.

Source: https://habr.com/ru/post/248839/


All Articles