Tuesday, 18 August 2020

Formatting Memory Sticks on Ubuntu for Use with Windows

When Windows 8 formats a memory stick, it uses partition type 'C'.


Identify USB device ID:

dmesg


Create Partition Table:

sudo fdisk /dev/sdx

Create Partition Type: C - W95 FAT32 (LBA)


Format Partition Disk:

sudo mkfs.vfat -F 32 -n "LABEL" /dev/sdxn


Monday, 22 June 2020

OpenScad Useful Functions

Some useful OpenScad functions / code

row = array_lookup(search, array, column)

OpenSCad doesn't support variable as such, so things need to be done recursively.
function array_lookup(query, source, column) = _array_lookup_rec(query, source, column, 0) ;
function _array_lookup_rec(query, source, column, row) =
    row>=len(source) ? len(source)-1 :
   query==source[row][column] ? row :
  _array_lookup_rec(query,source,column,row+1) ;
srcarray = [
[ "green", "apple", 5 ],
[ "green", "pear", 9 ],
[ "yellow", "banana", 5 ],
[ "ERROR", "ERROR", 0 ]
] ;
row1 = array_lookup("pear", scarray ,1) ;

i = toint(s)

This function uses recursion to work along the string.  It converts the supplied 's' to a string just in case an integer is supplied to the function.

// Safe Convert Decimal String to integer
function toint(st) = _toint_rec(str(st),0, 0) ;
function _toint_rec(st, idx, value) = (
    idx>=len(st) ? value
    : _toint_rec(st, idx+1, ( value*10 + ord(st[idx])-ord("0")) ) ) ;

prism(x,y,xm1,xm2,ym1,ym2,z,center)

This module produces a prism with a base which is X x Y and a height Z
The top edges can be moved in with the X and Y margins.
// prism base = x by y. left margin = xm1, bottom margin = ym1 etc.
module prism(x, y, xm1, xm2, ym1, ym2, z, center){
    CubePoints = [
        [ 0,  0,  0 ],  //0
        [ x, 0, 0 ],  //1
        [ x, y, 0 ],  //2
        [ 0, y, 0 ],  //3
        [ xm1,ym1, z ],  //4
        [ x-xm1, ym1, z ],  //5
        [ x-xm1, y-ym2, z ],  //6
        [ xm1, y-ym2, z ]]; //7
    CubeFaces = [
        [0,1,2,3],  // bottom
        [4,5,1,0],  // front
        [7,6,5,4],  // top
        [5,6,2,1],  // right
        [6,7,3,2],  // back
        [7,4,0,3]]; // left
    if (center) {
        translate([-x/2,-y/2,-z/2]) polyhedron(CubePoints, CubeFaces);
    } else {
        polyhedron(CubePoints, CubeFaces);
    }
} ;


USB Webcam(s) with Raspberry Pi

Configuration Steps


Update the Pi


sudo rpi-update

Ensure the right modules are loaded

lsmod | grep uvcvideo
uvcvideo               94208  1
videobuf2_vmalloc      16384  2 uvcvideo,bcm2835_v4l2
videobuf2_v4l2         28672  5 bcm2835_isp,uvcvideo,bcm2835_codec,bcm2835_v4l2,v4l2_mem2mem
videobuf2_common       57344  6 bcm2835_isp,uvcvideo,bcm2835_codec,bcm2835_v4l2,v4l2_mem2mem,videobuf2_v4l2
videodev              237568  8 bcm2835_isp,uvcvideo,bcm2835_codec,videobuf2_common,bcm2835_v4l2,v4l2_mem2mem,videobuf2_v4l2
mc                     45056  8 bcm2835_isp,uvcvideo,bcm2835_codec,snd_usb_audio,videobuf2_common,videodev,v4l2_mem2mem,videobuf2_v4l2
ls -la /dev/video?
crw-rw-rw- 1 root video 81, 0 Jun 22 14:17 /dev/video0
crw-rw-rw- 1 root video 81, 1 Jun 22 14:17 /dev/video1

Add any missing modules to  /etc/modules-load.d/video.conf

e.g.:  snd-bcm2835,  i2c-dev,  bcm2835-v4l2, uvcvideo

Disable PI (non USB) camera

raspi-config

Gotchas

In order for this to work, the /dev/video0 port must exist and be accessible.

Ensure the USB video is not blacklisted

sudo rm /etc/modprobe.d/ubcvideo-blacklist.conf

Ensure the port is accessible

chmod ugo+rw /dev/video?

(this is crude - the proper thing to do is ensure that the users accessing the camera are in the 'video' group).

Programs that use the camera

uv4l - conferencing tool
motion - security camera tool
ffmpeg - video streaming

MOTION

Note that motion supports video, but not audio.  This example configures it for streaming, and disables the local snapshots.

sudo apt-get install motion

vi /etc/motion/motion.conf
daemon on
output_pictures off
output_debug_pictures off
ffmpeg_output_movies off
ffmpeg_output_debug_movies off
ffmpeg_video_codec mpeg4
camera=/etc/motion/camera1.conf
camera=/etc/motion/camera2.conf
stream_localhost off
webcam_localhost off
camera1.conf:
camera_id = 1
videodevice /dev/video0
input -1
width W
height H
framerate F
v4l2_palette P
stream_port 8091

W,H,F,P characteristics can be identified with: ffmpeg -hide_banner -f v4l2 -list_formats all -i /dev/video0
Compressed: mjpeg : Motion-JPEG : 1920x1080 1280x720 640x360 1920x1080
Raw :  yuyv422 :  YUYV 4:2:2 : 640x360
Options for P are found in the comments in motion.conf
MJPEG = 8, YUYV = 15
The next camera goes in camera2.conf - It's videodevice will be /dev/video2 (not /dev/video1).  Make sure you pick a different ID and stream port.

Enable motion daemon
# sudo vi /etc/default/motion
Start motion
# systemctl enable motion
Check log files:
tail /var/log/syslog
dmesg
/var/log/motion/motion.log

FFMPEG / MKVSERVER

Building and Installing

Setup for cross-compiling on Linux PC
sudo apt-get install build-essential git-core
sudo git clone https://github.com/raspberrypi/tools.git /opt/tools
Fetch Repositories and ready for build
git clone git://source.ffmpeg.org/ffmpeg.git
cd ffmpeg
git clone https://code.videolan.org/videolan/x264.git
git clone https://github.com/klaxa/mkvserver_mk2.git
export CCPREFIX="/opt/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian-x64/bin/arm-linux-gnueabihf-"
Build ffmpeg and libraries
# Build x264
cd x264
./configure --host=arm-linux --cross-prefix=${CCPREFIX} --enable-static --disabl
e-asm
make
cd ..
# Build ffmpeg with x264
./configure --enable-cross-compile --cross-prefix=${CCPREFIX} --arch=armel --target-os=linux --enable-gpl --enab
le-libx264 --extra-cflags="-Ix264/" --extra-ldflags="-ldl -Lx264/"
make
cd ..
Modify mkvserver/Makefile
CC=${CCPREFIX}gcc
FFMPEG=../ffmpeg
LAV_LDFLAGS = -L ${FFMPEG}/libavcodec \
-L ${FFMPEG}/libavformat \
-L ${FFMPEG}/libavutil \
-L ${FFMPEG}/libswresample \
-L ${FFMPEG}/x264 \
-lavformat -l m \
-lavcodec -pthread -lm -lx264 -pthread -lswresample \
-lavutil -pthread -lrt -lm \
-lx264 -lpthread -lm -ldl
LAV_CFLAGS = -I${FFMPEG}
Build mkvserver
cd mkvserver
make
cd ..
Transfer 'server' to raspberry pi, name it mkvserver and place it in /usr/bin

Configuring and Launching


Useful Commands

lsusb
udevadm info -n /dev/video0
arecord -L / arecord -l
raspi-config
vcgencmd get_camera
ffmpeg -hide_banner -f v4l2 -list_formats all -i /dev/video0
v4l2-ctl --all








Installing and Configuring Raspberry Pi

Installation

1. Download

Download Image from https://www.raspberrypi.org/downloads/

2. Write Image

Plug memory card into a Linux PC

# Identify id of card which has just been plugged in
dmesg

# Copy the image onto the card
dd bs=4M if=<imagefile.img> of=/dev/sd<x>

Configuring (via HDMI)

Booting

Connect Pi to HDMI screen, and connect USB keyboard
Plug card into Pi, and turn on

Logging In and Enabling ssh

# Login with user/password as pi/raspberry

# Enable SSH (interfacing options, select Yes to SSH)
sudo raspi-config

# Reboot Pi
sudo reboot

Enabling Wireless

sudo raspi-config

Configuring (Headless)

Enabling SSH

# Remove and re-insert card into the Linux PC
# The drive should auto-mount

# Create an 'ssh enable' file
touch /mount/<user>/boot/ssh

Enabling Wireless

# Create a wireless configuration file
cat > /mount/<user>/boot/wpa_supplicant.conf 

country=GB ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev update_config=1 network={ ssid="your_real_wifi_ssid" scan_ssid=1 psk="your_real_password" key_mgmt=WPA-PSK }

Upgrading

sudo pri-update

References



Raspberry Pi IR


Notes to make IR shield (made by LinkSprite) work in Raspberry Pi 3 (bought from Amazon [1]).

The vendor has some documentation [2] but that is not complete and sufficient for Raspbian Stretch.
Following are the changes that I made to make it work.

$ sudo apt-get update
$ sudo apt-get install lirc

# Add the following lines to /etc/modules file
lirc_dev
lirc_rpi gpio_in_pin=18 gpio_out_pin=17

# Add the following lines to /etc/lirc/hardware.conf file
LIRCD_ARGS="--uinput --listen"
LOAD_MODULES=true
DRIVER="default"
DEVICE="/dev/lirc0"
MODULES="lirc_rpi"

# Update the following line in /boot/config.txt (incomment if required)
dtoverlay=lirc-rpi,gpio_in_pin=18,gpio_out_pin=17

# Update the following lines in /etc/lirc/lirc_options.conf
# Update the following lines in /etc/lirc/lircd.conf
driver    = default
device    = /dev/lirc0

# Reboot before testing
$ reboot

$ sudo /etc/init.d/lirc stop
$ sudo /etc/init.d/lirc start

# Check status to make lirc is running
$ sudo /etc/init.d/lirc status


# Populate lircd.conf

#
# this config file was automatically generated
# using lirc-0.8.6(default) on Fri Sep 10 22:02:46 2010
#
# contributed by
#
# brand:                       TV LG 42"LD420
# model no. of remote control: AKB72915207
# devices being controlled by this remote:
#

begin remote

  name  LG_AKB72915207
  bits           16
  flags SPACE_ENC|CONST_LENGTH
  eps            30
  aeps          100

  header       9056  4448
  one           601  1647
  zero          601   538
  ptrail        601
  repeat       9081  2199
  pre_data_bits   16
  pre_data       0x20DF
  gap          108229
  toggle_bit_mask 0x0

      begin codes
          KEY_POWER                0x10EF                    #  Was: power
          energy                   0xA956
          avmode                   0x0CF3
          input                    0xD02F
          tvrad                    0x0FF0
          KEY_1                    0x8877                    #  Was: 1
          KEY_2                    0x48B7                    #  Was: 2
          KEY_3                    0xC837                    #  Was: 3
          KEY_4                    0x28D7                    #  Was: 4
          KEY_5                    0xA857                    #  Was: 5
          KEY_6                    0x6897                    #  Was: 6
          KEY_7                    0xE817                    #  Was: 7
          KEY_8                    0x18E7                    #  Was: 8
          KEY_9                    0x9867                    #  Was: 9
          KEY_0                    0x08F7                    #  Was: 0
          KEY_LIST                 0xCA35                    #  Was: list
          q.view                   0x58A7
          KEY_VOLUMEUP             0x40BF                    #  Was: vol_up
          KEY_VOLUMEDOWN           0xC03F                    #  Was: vol_down
          KEY_CHANNELUP            0x00FF                    #  Was: ch_up
          KEY_CHANNELDOWN          0x807F                    #  Was: ch_down
          KEY_FAVORITES            0x7887                    #  Was: fav
          ratio                    0x9E61
          KEY_MUTE                 0x906F                    #  Was: mute
          KEY_MENU                 0xC23D                    #  Was: menu
          KEY_INFO                 0xD52A                    #  Was: guide
          q.menu                   0xA25D
          KEY_UP                   0x02FD                    #  Was: up
          KEY_DOWN                 0x827D                    #  Was: down
          KEY_LEFT                 0xE01F                    #  Was: left
          KEY_RIGHT                0x609F                    #  Was: right
          KEY_OK                   0x22DD                    #  Was: ok
          KEY_BACK                 0x14EB                    #  Was: back
          KEY_INFO                 0x55AA                    #  Was: info
          KEY_EXIT                 0xDA25                    #  Was: exit
          KEY_RED                  0x4EB1                    #  Was: red
          KEY_GREEN                0x8E71                    #  Was: green
          ellow                    0xC639
          KEY_BLUE                 0x8679                    #  Was: blue
          exit2                    0x04FB
          t.opt                    0x847B
          KEY_SUBTITLE             0x9C63                    #  Was: subtitle
          KEY_STOP                 0x8D72                    #  Was: stop
          KEY_PLAY                 0x0DF2                    #  Was: play
          KEY_PAUSE                0x5DA2                    #  Was: pause
          KEY_REWIND               0xF10E                    #  Was: <<
          KEY_FORWARD              0x718E                    #  Was: >>
          simplink                 0x7E81
      end codes

end remote


# To test if lirc output driver is working
$ irsend SEND_ONCE LG_AKB72915207 KEY_POWER


# To test if lirc input driver is working
$ sudo /etc/init.d/lircd stop
$ mode2 -d /dev/lirc0
<press a key in remote and you should see multple lines like below>
pulse 560
space 1706
pulse 535

# to record a custom remote/register a remote device
$ sudo /etc/init.d/lircd stop
$ sudo irrecord -d /dev/lirc0 ~/lircd.conf
# follow the instruction prompted by the above command carefully
# at the end ~/lircd.conf file will be generated

# backup the original lircd.conf
$ sudo mv /etc/lirc/lircd.conf /etc/lirc/lircd_original.conf
$ sudo cp ~/lircd.conf /etc/lirc/lircd.conf
$ sudo /etc/init.d/lircd start

# you can test if the recorded remote works by
$ irsend SEND_ONCE <device-name> KEY_POWER
$ irsend SEND_ONCE <device-name> KEY_VOLUMEUP

[1] https://www.amazon.com/Infrared-Shield-for-Raspberry-Pi/dp/B00K2IICKK/ref=pd_sbs_328_1?_encoding=UTF8&psc=1&refRID=1QPY33VFCGETBJ17K8QE
[2] http://learn.linksprite.com/raspberry-pi/shield/infrared-transceiver-on-raspberry-pi-lirc-software-installation-and-configuration/

Wednesday, 3 June 2020

Method For Calculating a 3D Printer Maximum Flow Rate

Abstract

This note describes the steps taken to test and measure the maximum filament flow rate supported by a 3D printer.

The flow rate depends on a number of factors, including:

  • Hot end heating capability: how quickly can the hot end get heat into the filament as it passes through.
  •  Filament and hot-end differential temperature: How much energy is taken from the hot end when the filament is melted.
  •  Drive capability of the extruder: How quickly can the extruder motor pass filament into the hot end.

Test Overview

The test passes different lengths of filament through the hot end at a set temperature over a fixed 10 second interval.

It is noted when the extruder starts to click / slip, and the extruded filament is weighed and compared against the expected results.

Download

Download the document here: Method for Calculating a 3D Printer Maximum Flow Rate

Sunday, 31 May 2020

XYZ Davinci Pro and Prusaslicer

Introduction

The XYZ Davinci Pro slicer is not particularly configurable, and if you have replaced elements such as the hot end and nozzle size and the extruder, it doesn't provide sufficient access to create effective g-code.

The Prusaslicer comes with a number of pre-configured machines and filaments, but the XYZ Davinci Pro isn't included amongst them.

PrusaSlicer Configured for the Davinci 1.0 Pro

Configuring the Printer

Once the software is installed, you should select the settings gears icon next to the printer drop-down.

General Settings


Max Height: 200
Z-Offset: 0
Number Extruders: 1
Print Upload: section is not applicable, you must use the XYZ or minimover software for upload.
G-code flavour: Marlin
Relative E-Distances: No
Firmware Retractions: No
Volumetric E: No
Variable Layer Height: Yes

Bed Shape: 200 x 200
Origin: 0, 0
Texture: Useful so you can remind yourself where the door is - note that the image is effectively upside-down - Save a copy of this image if it helps ... it is recommended that you save the file in the .PrusaSlicer folder so that all of the configurartion files are together.

Davinci Pro Bed Texture Image

Custom G-Code


The Custom G-Code us used to configure the printer at the start and end of the prints.  It also allows code to be inserted between layers, which is particularly useful with more advanced configurations.
The Custom G-Code accepts variables such as layer height and temperatures, and also accepts conditional statements.

The XYZ software is slow to start up, and only does one thing at a time - raise the bed, start the head heating, then start the bed heating.  It also lowers the bed after you press a button at the end of the print.  This G-Code attempts to speed these things up.

Note that the LCD panel on the printer is disabled until the monitor M108 command is seen in the G-Code, so it is essential that this is included as a minimum if you ever want to get to the Cancel menu option (for example) during a print.

The G-Code files can be found in the zipfile at the bottom of this blog.

Machine Limits

At the moment, I've left this section unedited as I've not experimented to identify what the actual limits are, so these can be left at their default.

Extruder 1



Nozzle Diameter: 0.4 for the stock extruder
Layer Height Min: 0.1
Layer Height Max: 75% of your nozzle diameter
Retraction: 2mm
Retraction Speed: 60mm/s
Wipe While Retracting: Yes
Retract Before Wipe: 10%

Note: As this is a bowden style printer (the drive is remote from the head), the control of the actual filament at the head is subject to inaccuracies due to the properties of the filament (e.g. elasticity).  Wiping while retracting can compensate somewhat for this.

Note on Retraction: If this is too far, or too fast, it can pull molten filament up into the heatsink part of the head, which can then cool and never melt again, causing a blockage.  Keep the retraction under 3mm.

Saving

Save the printer settings - if you have a head that allows you to change the nozzle size, make sure the nozzle size is part of the save name.

Now return back to the 'platter' tab / page.  You should now see that the print bed is using your texture.

Configuring the Filament


Select the settings gear icon next to the filament and create a new filament.

Unfortunately here, you don't seem to be able to copy / use the stock filaments database with your custom printer, but you can look at them at least.



Filament settings are normally specific to manufacturers and not printers. however, if you have replaced the extruder with one that passes filament at a different rate, you will need to compensate for that here, as the firmware on the printer assumes you are always using the default XYZ extruder.

If you have modified / replaced the extruder, you will have to compensate with the extrusion multiplier - start by setting the extrusion multiplier to 100 / actual amount of filament fed when 100mm requested - seem my blog on replacing the extruder for more information on measuring this.

It is important that you also set the maximum flow rate for the filament in the Advanced settings.  Now this will depend on whether you are using the stock hot end or have upgraded.  The maximum flow rate figures also need adjusting to compensate in the event that you have modified / replaced the extruder.

My settings are as follows:


Files Download

Settings Bundle: prusaslicer-davincipro-settings.zip


Wednesday, 27 May 2020

Replacing the Davinci 1.0 Pro Extruder with the WINSINN Ender 3 Dual Gear Extruder

Background


For my 7 year old Davinci 1.0 Pro printer, the extrusion has become unreliable.  I first put this down to blockages in the head, then the head itself, but replacing the head with an E3Dv6 did not really help much - yes, it can print in PETG with a 0.6mm nozzle, but can't print with PLA or with anything with a 0.4mm nozzle without the extruder skipping.

Model Suffering From Extrusion Problems


Solution

I bought an aluminium Ender3 dual-gear extruder, which actually bolts in in place of the default Davinci Pro one.  The new extruder is much simpler, and works fine without the sensor electronics that are part of the Davinci Pro system.

The following summary shows how the modification affects the printer.
  1. Loading filament works fine.
  2. When unloading, the printer no longer knows when to stop, so you have to select 'OK' manually.
  3. The size of the gear is smaller, and when you tell the printer to pass 100mm of filament, it passes a shorter length, so a compensation is required in the slicer.

Steps

Disassembly

  • Unload any filament currently being used.
  • Unclip the panel behind the printer (that the filament feeds through)
  • Open the lid and identify the location of the lid switch - you will need to avoid this.
  • Using the flat blade scraper, pop-off the left and right panels.
  • Reaching underneath, release the extruder cover and pull this away.
  • Disconnect the cable to the extruder sensor assembly.
  • Remove the complete extruder sensor assembly to the state where the motor is free-floating.
  • Note that the connector to the sensor board is not required, and can be left disconnected.

Assembly

Assembly Steps

Step A

  • Temporarily hold the motor in place with the small flat-headed screw
  • Using a small allen key, undo and remove the old drive teeth
  • Install the new drive teeth ensuring that the cog/gears are at the bottom.
  • loosely tighten the allen key such that the gears turning also turns the spindle.

Step B

  • Install the base part of the assembly using three screws, ensuring the countersunk screw is in the correct location.
  • Adjust the height of the gears using a piece of filament as a guide

Step C

  • Prepare the clamp part of the assembly, spring and screws as shown in the photograph

Step D

  • Install the spring between the captive screw and adjustment cap
  • Hold closed and install the long vertical bolt
  • Undo / tighten the spring tension screw until the spring just starts to rotate

Calibration Measurement

The new gearing has a different ratio to the original XYZ mechanism.  Extrusion is achieved using GCode commands which tell the motor to expel, say, 100mm of filament.  With a crafted gcode file, it is possible to measure the actual extrusion amount enabling an adjustment factor to be calculated.

This calibration section is optional - i.e. everyone _should_ get a similar answer, given the same original printer gearing and software, the same modified extruder gearing, and the same filament type and same environmental temperature ....

The following GCode achieves this:

G21 ; set units to millimeters
M108 ; Check Temperatures
M107 ; Fan Off
M191
G90 ; use absolute coordinates
G92 E0
G28 X0 Y0 ; home X and Y axes
Extrude 5mm
G1 F500 E5
; First Move ready to extrude 100mm
G1 X50 Y100
Extrude 100mm
G1 F500 E105
; Second Move ready to retract 100mm
G1 X150 Y100
Retrieve 100mm
G1 F500 E5
M103 ; turn off extruder and retraction
M104 S0 ; turn off extruder
M140 S0 ; turn off bed
M107 ; turn off fan
G28 X0 Y0 ; home X and Y axes
M84 ; disable motors
M82 ;absolute extrusion mode

  • Put a short length of filament into the feeder, and mark the position with an indelible marker as it goes into the feeder.
  • Paste the GCode into a file called 100mmextrude.gcode
  • Load this file into the XYZ software and send to the printer.
  • The printer will warm up and then home the head.
  • It will attempt to pass through 5mm of filament - at this point, mark the filament at the location where it goes into the feeder.
  • The printer will move the head (to give you time to mark) and then extrude 100mm of filament
  • Mark the new filament location.
  • The printer will move the head again before retracting the 100mm of filament - you should see your previous mark again.
  • Once the sequence is complete, remove and measure the distance between the two "100mm" marks.

If nothing changes, everyone should get a similar reading - which, for me was 70mm.


100mm Extrusion Filament Marking

Software Configuration

The printer does not give you access to program / configure the gear ratio,, nor does it support the M92 gcode command that would allow you to specify the extruder stepper ratio, so this has to be done in the slicer, when generating the GCode files for printing.

With the calibration measurement, an adjustment of 100/70 can be made for the extruder, i.e. 143% - i.e. the software needs to be told to use 143% of the filament it is expecting.

The option can be found in different places, depending on which slicer you are using:

  • Cura: Flow Rate
  • Slic3r: Filament Extrusion Multiplier
  • XYZ: Extrusion Ratio
Note that I have tried to use the Cura (4.5.0) Experimental Flow Rate Compensation Factor, and this did not appear to affect the resulting gcode file (apart from adding a comment in the header).

Note that this isn't an exact science (well it is, but the maths and the number of variables are far to complicated), and there are other aspects that are taken into consideration with the compensation factor - different filaments expand at different rates at different temperatures, so this factor will need tweaking for each filament supplier and material (just as before), but it now needs tweaking with more of an offset than before!











Sunday, 12 April 2020

Davinci 1.0 Pro - Wireless Network Configuration

An example of the serial protocol over the USB cable for the configuration of the wireless network on the Davinci 1.0 Pro is shown below.
The printer has the latest software as at 12th April 2020.

Software Connects to the Printer and Queries the Status

XYZv3/query=a
b:31
d:0,0,0
e:0
f:1,200000
i:3F1AWPEU4TH63AT000
j:9511
L:1,180660,30739
m:0,0,0
o:p8,t1,c1,a-
O:{"nozzle":"210","bed":"40"}
p:dvF1W0A000
s:{"fm":1,"fd":1,"dr":{"top":"off","front":"off"},"sd":"yes","eh":"0","of":"1"}
t:1,30
v:1.4.0
w:1,--------------
n:Davinci 3D
X:2,GB-0004-0000-TH-638-0141-38155
l:en
V:5.1.5
4:{"wlan":{"ip":"192.168.5.200","ssid":"BT","channel":"1","MAC":"11:11:11:11:11:11"}}
$
XYZv3/config=lang:[en]
ok
$
 
XYZv3/query=a 
b:32
d:0,0,0
e:0
f:1,200000
i:3F1AWPEU4TH63AT000
j:9511
L:1,180660,30739
m:0,0,0
o:p8,t1,c1,a-
O:{"nozzle":"210","bed":"40"}
p:dvF1W0A000
s:{"fm":1,"fd":1,"dr":{"top":"off","front":"off"},"sd":"yes","eh":"0","of":"1"}
t:1,30
v:1.4.0
w:1,--------------
n:Davinci 3D
X:2,GB-0004-0000-TH-638-0141-38155
l:en
V:5.1.5
4:{"wlan":{"ip":"192.168.5.200","ssid":"BT","channel":"1","MAC":"11:11:11:11:11:11"}}
$

Disconnect from Network

XYZv3/config=disconnectap
ok
$

Query the Available Wifi Networks

XYZv3/query=W 
W:[{"ssid":"BT","bssid":"11:11:11:11:11:11","channel":"1","rssiValue":"-82","security":"8"},{"ssid":"Home","bssid":"55:55:55:55:55:55","channel":"5","rssiValue":"-79","security":"8"},{"ssid":"SKYSQCYR","bssid":"66:66:66:66:66:66","channel":"6","rssiValue":"-83","security":"8"},{"ssid":"Virgin Media","bssid":"bb:bb:bb:bb:bb:bb","channel":"11","rssiValue":"-86","security":"32"}]
$

Select and attempt connection

XYZv3/config=ssid:[Home,PASSWORD,5] 
ok
$

Query the current connection

XYZv3/query=4
4:{"wlan":{"ip":"192.168.1.100","ssid":"Home","channel":"5","MAC":"55:55:55:55:55:55"}}
$

Monday, 30 March 2020

BackupPC 4.3.2 for Linux and WIndows 10

Introduction

These instructions are provided for the installation and configuration of BackupPC 4.3.2 on a Linux server, and the configuration for remote backup of Windows clients.

Note that later version (4.3.2) configuration method is different to previous version 3

Installation

Create Some Storage Areas
mkdir /disk/backup/backuppc
mkdir /disk/media/www/cgi-bin
mkdir /disk/media/www/html
mkdir /disk/media/www/log
mkdir /disk/media/www/etc
Configure Apache2 to Support BackupPC

Install Apache2
Add a new virtual host .conf file in /etc/apache2/sites-enabled
<VirtualHost *:80>
DocumentRoot /disk/media/www/html
ErrorLog /disk/media/www/log/error.log
CustomLog /disk/media/www/log/access.log combined
ScriptAlias /cgi-bin/ /disk/media/www/cgi-bin/
<Directory "/disk/media/www/cgi-bin" >
        Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
AllowOverride None
Require all granted
</Directory>
<Location "/cgi-bin">
AuthType Basic
AuthName "Backup PC"
AuthUserFile /disk/media/www/etc/htpasswd
Require valid-user
</Location>
</VirtualHost>

Create User

Create a user and group called 'backuppc'
useradd backuppc
htpasswd -c /disk/media/www/etc/htpasswd backuppc
Installing and Configuring BackupPC on Server

Download latest backuppc from https://github.com/backuppc
Also, download and build rsync-bpc

Install BackupPC::XS libraries from github, or with cpan:
sudo cpan install BackupPC::XS
Unpack and install the backuppc application:
sudo ./configure.pl
Install Directory: /usr/local/BackupPC
Data Directory: /disk/backup/backuppc
CGI Directory: /disk/media/www/cgi-bin
Apache Image Directory: /disk/media/www/html/BackupPC

Windows 10 Backup Configuration

On a Windows Client

Note that you don't have to create any special backuppc user on the Windows machine

Install cygwin-rsyncd on Windows PC
Control Panel Firewall, and allow c:\rsyncd\bin\rsyncd.exe access
Set Username / Password and Share in c:\rsyncd\rsyncd.conf and rsyncd.secrets

On Backup Server

Set client to have static IP
Configure server to use rsyncd
Specify location of rsync client as /usr/local/bin/rsync_bpc
Add Username / Password details
Add Share Name as per Windows client (no leading slash, just the name)
Add same Username / Password as was set up on the Windows client

Add Excludes for Share Name, for example:
/AppData
/NTUSER.*
/MicrosoftEdgeBackups
/$RECYCLE.Bin
/OneDrive
/Temp
/Downloads

Linux Backup Configuration

On a Remote Linux Machine

Configure ssh such that root logins are accepted from the backuppc user on the backup server
backuppc@backupserver$ sshkeygen -t rsa
backuppc@backupserver$ cat id_rsa.pub | ssh -l root client "cat >> ~/.ssh/authorized_keys"
root@client's password: ******
backuppc@backupserver$ ssh -l root client
root@client#

Configure server to use rsync
Specify location of client's rsync as /usr/bin/rsync
And the location of ther server's rsyng to /usr/local/bin/rsync_rpc
No username or password is required, because this is done over ssh
Add the name of the path to backup, e.g. /home
Add Excludes for /home, for example:
*.ts
*~
tmp/*

Common Errors

AH01215: (13)Permission denied: exec of BackupPC_Admin failed

Ensure the file is in the same group as the www server
chgrp htdocs /disk/meida/www/cgi-bin/BackupPC_Admin

Empty Admin Web Page, or Error: Unable to read config.pl or language strings!!
If you've not been prompted for a username / password, check the AuthUserFile configuration.

Then, check the user and permissions of the files in /etc/BackupPC, and the permissions of the executable program in /disk/media/www/cgi-bin.

It is possible that your configuration is not allowing setuid on perl scripts. If so, re-name the BackupPC_Admin file to BackupPC_Admin.pl, and then build this program:
#include <unistd.h>#define REAL_PATH "/disk/media/www/cgi-bin/BackupPC_Admin.pl"int main(ac, av)char **av;{   execv(REAL_PATH, av);   return 0;}


Then set the programme's permissions:

chown backuppc:httpservergroup BackupPC_Adminchmod ug+s BackupPC_Admin


Unable to Add or Manage Hosts / Only Privileged Users ...


Edit /etc/BackupPC/config.pl, and set the users to include backuppc
$Conf{CgiAdminUserGroup} = 'httpservergroup';$Conf{CgiAdminUsers}     = 'backuppc';

xfer start failed: $Conf{RsyncBackupPCPath} is set to , which isn't a valid executable

Set global rsync application in Server/Edit Config to /usr/bin/rsync (or appropriate path)

rsync_bpc: failed to connect to windows10machine (192.168.1.10): Connection timed out (110)
or 4 Bytes Copied

Check the service is running on the Windows machine, and check the firewall is not blocking it (look for port 873 being open)
nmap 192.168.1.10
Starting Nmap 7.01 ( https://nmap.org ) at 2020-03-30 15:06 BST
Nmap scan report for zenbook-martine (192.168.1.10)
Host is up (0.0022s latency).
Not shown: 995 filtered ports
PORT STATE SERVICE
135/tcp open msrpc
139/tcp open netbios-ssn
445/tcp open microsoft-ds
873/tcp open rsync
5357/tcp open wsdapi
MAC Address: AA:BB:CC:DD:EE:FF (Unknown)
Nmap done: 1 IP address (1 host up) scanned in 23.31 seconds
If you don't see 873/tcp, you will need to make sure rsync is running, and also ensure the firewall port is open:
Windows Defender Firewall / Advanced / Inbound Rules / New Rule / Port 873/tcp, Open for Domain and Private Netoworks.

Friday, 14 February 2020

Cross-Compiling ffmpeg for arm7l Enigma2 Receiver on Ubuntu


Purpose

Convert transport streams for
Download and Configure the Cross-Compiling Tools


sudo apt-get install libc6-armel-cross libc6-dev-armel-cross binutils-arm-linux-
gnueabi libncurses5-dev

Build the 264 Codec Library (libx264)

There are two 264 libraries - openh264 (Cisco) and libx264 (Videolan).  libx264 provides higher quality outputs, and is the library of choice.

Clone from https://code.videolan.org/videolan/x264.git
export CC=arm-linux-gnueabi-gcc
export CXX=arm-linux-gnueabi-g++
export LD=arm-linux-gnueabi-ld
export AR=arm-linux-gnueabi-ar
export NM=arm-linux-gnueabi-nm
export RANLIB=arm-linux-gnueabi-ranlib
./configure  \
  --prefix=/usr/arm-linux-gnueabi \
  --exec-prefix=/usr/arm-linux-gnueabi \
  --enable-static \
  --host=arm-linux-gnueabi
make
sudo make install




Build the Lame MP3 Library

Fetch from: https://sourceforge.net/projects/lame/files/lame/
export CC=arm-linux-gnueabi-gcc
export CXX=arm-linux-gnueabi-g++
export LD=arm-linux-gnueabi-ld
export AR=arm-linux-gnueabi-ar
export NM=arm-linux-gnueabi-nm
export RANLIB=arm-linux-gnueabi-ranlib
./configure CC=arm-linux-gnueabi-gcc \
  --prefix=/usr/arm-linux-gnueabi \
  --exec-prefix=/usr/arm-linux-gnueabi \
  --enable-static --disable-shared \
  --host=arm-linux-gnueabi
make
sudo make install

And build the ffmpeg / ffprobe binaries

Clone from: https://git.ffmpeg.org/ffmpeg.git
./configure --target-os=linux \
  --arch=arm7l \
  --prefix=/usr/arm-linux-gnueabi \
  --enable-cross-compile \
  --cross-prefix=arm-linux-gnueabi- \
  --logfile=configure.log \
  --extra-ldflags=-static \
  --pkg-config-flags="--static" \
  --enable-nonfree \
  --enable-gpl \
  --enable-libx264 \
  --enable-libmp3lame

make
sudo make install
sudo make install-libs
 

Build LibTesseract
Clone From: https://github.com/tesseract-ocr/tesseract.git

Build CCExtractor

Clone From: https://github.com/CCExtractor/ccextractor.git

cd linux
./autogen.sh



Build the Ogg  Library

Fetch from: Github



git clone https://github.com/xiph/ogg.git
cd ogg
autogen.sh
CC=arm-linux-gnueabi-gcc ./configure \
  --prefix=/usr/arm-linux-gnueabi \
  --exec-prefix=/usr/arm-linux-gnueabi \
  --enable-static --disable-shared \
  --host=arm-linux-gnueabi
make
sudo make install

Build the Vorbis Library

Fetch from Github:

git clone https://github.com/xiph/vorbis.gitcd vorbisautogen.shCC=arm-linux-gnueabi-gcc ./configure \  --prefix=/usr/arm-linux-gnueabi \  --exec-prefix=/usr/arm-linux-gnueabi \  --enable-static --disable-shared \  --host=arm-linux-gnueabi
makesudo make install

Build ZLib

Fetch from: https://www.zlib.net/

CC=arm-linux-gnueabi-gcc ./configure --prefix=/usr/arm-linux-gnueabi --static
make
sudo make install