Browsing Tag
linux

The Honeywell QR reader will be our USB serial device to connect.

Recently I’m working on a project where i need to connect two Honeywell QR readers. The model to connect is the YJHF600 through the usb serial communication with a Raspberry Pi. For this i need to get the QR code scanned using golang as code language.

I will do a reader test of the QR code with the python language because the fastest to code and to prototype with this language

comunicación usb serial con Python y Raspberry PI

Honeywell QR reader – Raspberry Pi

How the usb communication for Honeyweel readers works?

Like most barcode readers, QR readers often emulate a keyboard and transmit the scanned information as if had been typed. In other words, our device to which we connect the readers usually see them as if they were a qwerty keyboard.

Some readers can be configurated as usb serial communication. This is the case if the Honeywell YJHF600 QR reader. For this reader all we have to do is scan the configuration code provided in the Honeywell reader manual with the QR readers and they will be automatically configured to generate this serial usb communication.

Testing the usb serial commutication between our Raspberry Pi and our Honewell Qr reader

Since we have configured and connected our serial usb device on the Raspberry Pi, we execute the command

Go en Raspberry Pi

How to setup the default GO language version of the Raspberry Pi with the APT INSTALL command

Setup the Go languague on the raspberry Pi is usually something very easy to do when we are using the apt package manager of the Raspberry Pi. We just need to execute:

sudo apt update
sudo apt install golang

However, the default version of Golang for the Raspberry Pi is not the last version of GoLang. And by this we will to unistall this version in case we had installed it and we are going to setup the last version from the official website.

sudo apt remove golang
sudo apt-get autoremove
source .profile

How to setup the last version of Go language from him source code

Once we have use the above commands and therefore we have deleted the Golang version loaded with the APT package manager. Now we will download and setup the last version of Go language from the golang official website.

Just as Node.JS has NPM or Ruby has Bundler, in PHP we have PHP Composer. It is a package manager that makes it easier for us to manage the depedencies of the libraries we work with our PHP Projects.

Installing PHP Composer

If you are a windows user, just download the installer always from their official site: https://getcomposer.org/Composer-Setup.exe

I personally work with Debian Linux, but the steps i am going to show you work similarly in Ubuntu and other Debian child distributions.

We download the PHP Composer

curl -sS https://getcomposer.org/installer -o composer-setup.php

We execute your installation

sudo php composer-setup.php --install-dir=/usr/local/bin --filename=composer

Executing the above will throw us the following over the command line.

composer php setup

I have found a mysql error while trying to start a mysql database server. The error is relative to the tc.log file at the startup process of mysql database server.

[Note] Recovering after a crash using tc.log
[ERROR] Can't init tc log
[ERROR] Aborting
Why has this mysql error ocurred?

In a quick review of the server, for this case these have been the problems.

  • Low hard disc space.
  • The log file tc.log was corrupted due to low hard disc space.
  • Lack of prevention by not having a resource monitoring for the server.

As sysadmin the first thing we always do is to analyze the log files of the server. At 90% of the cases we can found in this files how to solve the issue. in this case for the mysql error we have found that the problem is at the startup process of mysql database server, specifically in the log system. Possibly because of a lock in the file tc.log

The solution to the mysql error after checking the server
  • Free up disk space (this was the trigger of the problem).
  • Delete the log file tc.log sudo mv /var/lib/mysql/tc.log /var/lib/mysql/tc_bk.log this way mysql will be able to generate the tc.log file at the next start up.
  • As a prevention for future cases, we must to program alarms to notify the client when the server is in a critical situation regarding its resources.

In this case after freeing up the disk space. The server should have been booted up without any problem but one more time instead of booting the server correctly the mysql error persist. So what we proceed to do is a simple file deletion. For security reasons back it up instead of doing a direct deletion.

Basic server failure prevention policies

It is important to always have a minimum of active prevention policies to avoid failures that could leave the server inoperable. Something as basic as setting up threshold for the server resources as memory or disk space could help us avoid a bigger problem like the database getting up corrupted.

In this case because of no prevention policy to avoid server failures we have setup some basics system notifications for the server resources. Notifications for:

  • Mysql Database
  • Server Memory use threshold
  • Hard disk use space threshold
  • CPU use threshold

These threshold notification can be easily configured in case of operating under Amazon services from the same Amazon management console. the same applies for Rackspace, Microsoft Azure and similar cloud providers.

Aquí puedes dar clic para visualizar está entrada en español.