Monday, 9 November 2020

Prusa Slicer Pausing Octoprint and MK3S to Embed Magnets

Background

There are many ways of pausing a 3D printer in order to insert magnets, all of which require the GCode (which is downloaded to the printer) to be modified.

This note takes you through a quick how-to, and a few common methods.

Inserting the GCode

The easiest way to insert the GCode to trigger a pause is to do it within PrusaSlicer.  Immediately after you have sliced your model, you can drag the vertical slider to the right of the platter image down to the layer at which you want to insert a pause.

Simply right-click on the (+) to get to the insert GCode options.

Hint: If you don't see a (+), make sure that your Print Settings / Output Options / Sequential Printing / Complete Individual Options is disabled.

Using the M600 Option

M600 Pause Showing
Bleed-Through

M600 is designed to allow a filament change.  What the printer does, is push the job to the back so that the head can be easily accessed.  It should be noted that the head belt is locked quite tightly so it will be very difficult to knock out the print alignment when the job resumes.

It forces you to go through a removal and re-insertion of the filament.

The removal and re-insertion of the filament can cause bleed through of other colours that have been in the head beforehand.  This can be seen in the photo on the right.

However it performs a good retraction and pre-load so that there are no gaps in the final item.


M601 Resuming after heatbed has
been allowed to cool down

Using the M601 Option

M601 is a Pause Print command - unlike the M600 option this pushes the print job forward so that it can be accessed.  It doesn't go through a filament reload sequence, and it allows you to restart the printing through the front panel.

Note that the way the M601 code operates within the Prusa printer has evolved over time, and there have been problems with continuous loops.

The head and bed cool down whilst paused, and heat up again afterwards, which can result in parts becoming detached when printing resumes.


Using Custom G1/M1 Code

The G1 code is used to move the print head, and the M1 code is used to pause/ resume.

G1 X10.000 Y200.000 E0;

M1;

In this case, the job is pushed forward so it can be accessed, but in this case, the restart has to be done through the Octoprint interface (Resume is not offered on the front panel).

This code does not result in the bed or head cooling down, so the part remains adhered to the bed (at least until any safety timeouts occur).

Because the head remains heated, and no retraction is performed, it will tend to ooze, and when the print resumes, there may be missing filament as can be seen in the left-hand image below.

This can be "hidden" by changing the print to print the internal fill first, and the external layer last.  This should not be a method of choice if your print job has overhangs, however.

Print Pause using G1/M1 with Perimeters First shown on the left,
and Infill First shown on the right


Using Custom Octoprint Pause


In this case, Octoprint itself is responsible for managing the pause.  

Octoprint can intercept the @pause instruction, which can be be inserted into the GCode at the desired layer using the mechanism described above  Note that this command must be in lower case, otherwise the pause is ignored.

In the Octoprint Settings / GCode Scripts, there are two sections for before and after pause.  It is important that the crafted code is consistent with whether the print jobs are constructed using absolute / relative coordinates.

So in the Printer Advanced settings, make sure that "Use relative E distances" is selected. If you are going to use the following code.

The following code retracts filament, moves the head away, and then leaves the heatbed on, but allows the head to cool down to half its normal temperature.

On resuming, the head is heated up to its normal temperature + 5 degrees (in this example).  The head is primed and a compensation for any oozing or stringing is applied.  The head is then set to drift back its normal temperature as printing resumes.

In Octoprint, Insert the following GCode into the "After print job is paused" section:

{% if pause_position.x is not none %}

  M300 S261.63 P100 ; Beep C4

  ; relative XYZE
  G91
  M83


  ; retract filament
  G1 E-2.5 F4500

  ; move Z slightly upwards
  G1 Z+15 F4500

  ; absolute XYZE
  M82
  G90

  M300 S329.63 P100
; Beep E4

  ; move to a safe rest position, adjust as necessary
  G1 X20 Y180

  {% if pause_temperature[0] and pause_temperature[0]['target'] is not none %}

      ; set temp to orgtemp/2 but don't wait
      M104 S{{pause_temperature[0]['target']/2}}

  {% endif %}

  M300 S440.00 P100 ; Beep A4

{% endif %}


And the following GCode into the "Before print job is resumed" section (note see below for compensation factor):

{% if pause_position.x is not none %}

  ; absolute XYZ

  G90

  ; relative extruder

  M83

  M300 S261.63 P100 ; Beep C4

  ; set temp to orgtemp and wait

  {% if pause_temperature[0] and pause_temperature[0]['target'] is not none %}

      ; set temp to orgtemp and wait

      M109 S{{pause_temperature[0]['target']}}

  {% endif %}

  M300 S329.63 P100 ; Beep E4

  ; prime nozzle

  G1 E-2.5 F4500

  G1 E2.5 F4500

  G1 E2.5 F4500

  {% if pause_temperature[0] and pause_temperature[0]['target'] is not none %}

      ; set temp to slightly increased orgtemp and wait

      M109 S{{pause_temperature[0]['target']+5}}

      ; set temp to orgtemp but don't wait

      M104 S{{pause_temperature[0]['target']}}

  {% endif %}

  ; Ooze compensation

  G1 E<<compensation factor>> F4500

  M300 S440.00 P100 ; Beep A4

  ; absolute E

  ;M82

  ; reset E

  G92 E{{ pause_position.e }}

  ; move back to pause position XY

  G1 X{{ pause_position.x }} Y{{ pause_position.y }} F4500

  ; move back to pause position Z

  G1 Z{{ pause_position.z }} F4500

  ; reset to feed rate before pause if available

  {% if pause_position.f is not none %}

      G1 F{{ pause_position.f }} 

  {% endif %}

{% endif %} 

Note that the above scripts support a printer with a single head (i.e. pause_temperature[0] refers to the first head).


Oozing Compensation

Despite all effort, the printer will still lose some filament through oozing or stringing during the pause process.  A larger retraction could be applied, but there is always the danger of retracting hot filament into the thermal break.

If you can measure the amount of filament oozed (or more likely, left stringing when the head retracts) and this amount of filament is of a relatively consistent size, you can apply a compensation factor which will further pre-load the head.  If you do not need this factor, you can simply comment out the line in the GCode.

The compensation factor depends on the size of filament used, and size of nozzle.  Use the following table to translate oozed/strung mm of filament to an E compensation factor.



 

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



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