недеља, 18. јун 2017.

A red button that really does something

I have a DLINK DNS-325 network storage and it can work as a print server. I have connected my HP LaserJet 1020 printer to it and for past six years I was able to print using that print server. However, whenever I needed to print on two sides, or needed to add more paper, or had a paper jam and then wanted to continue printing, I wasn't able to proceed with the print. The red LED would blink, but the printer doesn't have the button to continue printing.
When that printer is connected to your PC, the driver takes care of those situations and offers you to click somewhere on the screen to continue printing. With this print server, that option was no longer available.
That was quite unpleasant situation, but I was able to resolve it by finding out that on the internal NAS web site, among printer server options, there was a "Clear print queue(s)" button, which continues with the printing. I was able to figure out the URL which was hit by the button, and fortunately, that URL didn't require user to log on. The URL is something like this:


http://<NAS_IP_ADDRESS>/cgi-bin/system_mgr.cgi?cmd=cgi_clear_print


I have placed an icon on my desktop as a shortcut with the address above. However, that fix required me to leave the printer and go back to the computer to click on that icon on my desktop, to continue with the printing. That is where one of my raspberry pi devices came in - I have connected a button to the pi and whenever I press that button, the Python code visits the URL above and flushes the print buffer, continuing the print.


Here is the Python code:

def edge_detected(channel):
print 'EDGE detected, channel is ', channel
val = GPIO.input(PORT_SWITCH)
if val == 0:
print "FLUSH!"
try:
r = requests.get('http://x.y.z.w/cgi-bin/system_mgr.cgi?cmd=cgi_clear_print') 
print r.text
except:
print str(sys.exc_info())

GPIO.add_event_detect(PORT_SWITCH, GPIO.BOTH, callback=edge_detected, bouncetime=50) 

The code above uses the Requests library.

One day I will connect my printer to the RPI instead of NAS, but so far, this works.

понедељак, 5. јун 2017.

Orange PI Zero and the Toy Car

This is a followup of my original post.

As I promised in my previous post, I am writing this post to share my experience with the Orange PI Zero and my toy car. The board is very small, and has almost all you need, except for the HDMI video output, which I don't need for my project. Therefore, it is perfect for me.

First of all, I have placed a small heat sink ond the SoC, since it can get quite hot (sometimes around 65°C). Next, I have placed the board on the car chassis and secured it with two screws. OPI Zero has both Ethernet and WiFi onboard, and even has the built-in antenna.

Since it does not have the HDMI, the only way I could configure it was to use the serial port. OPI has excellent support for serial console. Next to the Ethernet connector, there are three pins for Tx, Rx and GND. Thanks to that, I was able to set my WiFi using serial console, and from that moment on, I could SSH to it via WiFi.

OPI board 

The car now looks like this:

With everything added...

GPIO port does not have pins, so you need to solder them yourself. I have soldered seven pins (4 for the motor control, 2 for +5V/GND, and one for the signal which turns on/off headlights). You can see those seven pins on the top right corner of the picture above.

Next came the software. I want to state that the armbian support for the Orange PI is perfect. Everything works out of box. When I have configured the WiFi to connect to my home router, I was able to install all the software via SSH.

First I had to install the GPIO support. I have dowloaded and installed the orangepi_PC_gpio_pyH3 library, made by the duxingkei chow:

https://github.com/duxingkei33/orangepi_PC_gpio_pyH3

This library is similar to the one I have on the Raspberry Pi. Not the same - just similar enough.

The next step was to install the mjpeg streamer. I have installed it, but it could not run, saying that the libjpeg is missing. The only way I could make it work was to manually download the libjpeg8_8d1-2_armhf.deb file and to install it from that .deb file.

Next came the new kind of problem: mjpeg streamer crashed with this misleading stupid error message, when I tried to stream from two cameras at the same time:

Unable to start capture: No space left on device...

This does not have anything with the free drive space. It simply says that the complete bandwidth of the USB controller is consumed by the first web cam and it cannot stream from the second web cam. It simply cannot work with two Logitech C170 cameras.

I have tried to set the number of quirks for the driver, but it didn't work.

Fortunately, I had one Logitech C210 web cam (lower resolution - lower bandwidth) and that was good enough for the poor USB controller on the OPI Zero: one C170 (forward cam) and one C210 (rear cam).

The WiFi antenna is not so powerful as I have hoped, but it indeed works better than the small Realtek USB dongle which I had previously. The Ralink-based dongle and antenna I have described on my first post works the best, but I already have the built-in adapter and the antenna, so I will stick to that one.

That is about it. I am very satisfied with the Orange PI. I have tried both Lite and Zero boards, and they work excellent, considering the price and features. The only drawback of the Zero model is its limited USB bandwidth and the high core temperature. But, I can live with it...