The Smell of Molten Projects in the Morning

Ed Nisley's Blog: Shop notes, electronics, firmware, machinery, 3D printing, laser cuttery, and curiosities. Contents: 100% human thinking, 0% AI slop.

Category: Software

General-purpose computers doing something specific

  • RPi: Logitech Camera Data

    After installing things like imagemagick and mjpg_streamer on the Raspberry Pi, I exhumed a quartet of Logitech cameras from the heap to see how they worked. None bear any identification, apart from a tag on the cable, so here’s what I found out for later reference.

    They’re all reasonably good for still pictures, if you don’t mind terrible initial exposures. The default program works OK:

    fswebcam -d /dev/video0 -r 320x240 image.jpg
    

    On the other hand, getting any streaming video requires searching through the parameter space, which wasn’t helped by the total lack of documentation. The Arch Linux wiki has a useful summary of camera & drivers, with pointers to additional lists-of-lists. The OctoPrint repo documents the mjpg-streamer plugin parameters.

    So, we begin…

    This camera, one of two identical cameras in the heap, has a clip that used to fit on the upper edge of a laptop display:

    Logitech QuickCam for Notebook Plus - front
    Logitech QuickCam for Notebook Plus – front

    One has a tag:

    Logitech QuickCam for Notebook Plus - tag
    Logitech QuickCam for Notebook Plus – tag

    To make the tag data more useful for search engine inquiries:

    • M/N: V-UBG35
    • P/N: 861228-0000
    • PID: CE64105

    From lsusb:

    Bus 001 Device 008: ID 046d:08d8 Logitech, Inc. QuickCam for Notebook Deluxe
    

    With Raspbian on the RPi, 640×480 video tears and stutters, leaving 320×240 as the least-worst alternative:

    mjpg_streamer -i "/usr/local/lib/input_uvc.so -r 320x240" -o "/usr/local/lib/output_http.so -w /usr/local/www"
    

    The cameras don’t support YUYV at all and the video quality is mediocre, at best, but they do have a manual focus ring that lets you snuggle the camera right up against the subject.

    This ball camera:

    Logitech QuickCam Pro 5000 - on tripod
    Logitech QuickCam Pro 5000 – on tripod

    Has a tag:

    Logitech QuickCam Pro 5000 - tag
    Logitech QuickCam Pro 5000 – tag

    Which reads:

    • M/N: V-UAX16
    • P/N: 861306-0000
    • PID: LZ715BQ

    From lsusb:

    Bus 001 Device 009: ID 046d:08ce Logitech, Inc. QuickCam Pro 5000
    

    It requires YUYV at 320×240 (on the Pi) and nothing else works at all:

    mjpg_streamer -i "/usr/local/lib/input_uvc.so -r 320x240 -y" -o "/usr/local/lib/output_http.so -w /usr/local/www"
    

    It produces even worse video than the Notebook camera.

    This HD 720p camera has C130 scrawled on the front in my handwriting:

    Logitech HD Webcam C510 - front
    Logitech HD Webcam C510 – front

    And a tag:

    Logitech HD Webcam C510 - tag
    Logitech HD Webcam C510 – tag

    Bearing this text:

    • M/N: V-U0016
    • P/N: 860-000261
    • PID: LZ114SF

    The scrawled C130 doesn’t match up with what lsusb reports:

    Bus 001 Device 010: ID 046d:081d Logitech, Inc. HD Webcam C510
    

    It produces very nice results in many resolutions, using YUYV mode, although I think its native resolution is 1280×720 and that works perfectly on the Pi:

    mjpg_streamer -i "/usr/local/lib/input_uvc.so -r 1280x720 -y" -o "/usr/local/lib/output_http.so -w /usr/local/www"
    

    Video over USB is mysterious…

  • Raspberry Pi Setup Tweaks

    Things to remember during Raspberry Pi setups…

    You can do some of this through raspi-config.

    The NOOBS setup configures the HDMI video parameters to work with the worst possible display, so edit the /boot/config.txt (per the Official Doc):

    • Comment out all the NOOBS auto-configuration entires at the bottom
    • Set disable_overscan=1

    The highest mutually compatible setting for the U2711 monitor was 1920×1080@60Hz, which turned out to be CEA Mode 16 and was automagically selected as the monitor’s “native” mode. Disabling overscan lets the X session use the entire monitor screen, rather than being confined within the (huge) black overscan borders.

    That requires a power off-on cycle to take effect. Shut down properly with sudo shutdown -H now or just sudo halt.

    To set the default size of the lxterminal window so that it’s big enough to be useful, edit the Exec entry (down near the bottom) in /usr/share/raspi-ui-overrides/applications/lxterminal.desktop to read:

    Exec=lxterminal --geometry=80x60
    

    The Droid font family seems more readable than the default selection.

    Create a user for yourself, just so SSH will eventually work the way it does for all the other boxes. The group list comes from the default pi user:

    sudo adduser ed
    sudo usermod -a -G pi,adm,dialout,cdrom,sudo,audio,video,plugdev,games,users,netdev,input,spi,gpio ed
    

    Regrettably, the default pi user has the same numeric ID as the one I use on all the other boxes, which leads to problems with file sharing permissions. I may need to swap numeric IDs to make this work out correctly.

    To set a static IP, edit /etc/network/interfaces thusly:

    #iface eth0 inet dhcp     <-- comment this out to stop DHCP
    
    auto eth0
    iface eth0 inet static
     address 192.168.1.9      <-- obviously, pick your own
     gateway 192.168.1.1
     netmask 255.255.255.0
     network 192.168.1.0
     broadcast 192.168.1.255
    

    Change the hostname in /etc/hostname and /etc/hosts.

    Set up SSH for public-key access on an unusual port by editing /etc/ssh/sshd_config:

    1. Port 12345 <— choose your own
    2. PermitRootLogin no
    3. PasswordAuthentication no

    Create the ~/.ssh directory and put your own public key in it, which you can do from the remote system:

    scp ~/.ssh/id_rsa.pub octopi-1:.ssh/authorized_keys
    # a dummy line to reveal underscores in the previous line
    

    Twiddle ~/.ssh/config on the remote box to include the Pi and specify the unusual port:

    Host octopi-1 thisone thatone anotherone
    	ForwardX11	yes
    	Port	12345   <--- pick your own
    	User	ed
    

    Using ssh-agent -t 4h helps relieve the tedium of typing your passphrase all the time. Then sudo service ssh restart on the pi will require you to use your key passphrase; it’s a Good Idea to remain signed in through Port 22 with the original authorization while you fiddle with this stuff, then sign out when it all works.

    Update with the usual routine:

    sudo apt-get update
    sudo apt-get upgrade
    sudo apt-get dist-upgrade    <-- for system-level update
    sudo apt-get clean           <-- flushes /var/cache/apt/archives to save space
    
  • MakerGear M2: Marlin 1.0.2 Firmware Tweaks

    Given that I’m throwing all the balls in the air at once:

    • V4 hot end / filament drive
    • 24 VDC motor / logic power supply
    • PETG filament

    It seemed reasonable to start with the current Marlin firmware, rather than the MakerGear version from long ago. After all, when you file a bug report, the first question is whether it happens with the Latest Version.

    Marlin has undergone a Great Refactoring that moved many of the constants around. I suppose I should set up a whole new Github repository, but there aren’t that many changes and I’ve gotten over my enthusiasm for forking projects.

    Anyhow, just clone the Marlin repo and dig in.

    In Marlin_main.cpp, turn on the Fan 1 output on Arduino pin 6 that drives the fans on the extruder and electronics box:

    pinMode(6,OUTPUT);	// kickstart Makergear M2 extruder fan
    digitalWrite(6,HIGH);
    

    You could use the built-in extruder fan feature that turns on when the extruder temperature exceeds a specific limit. I may try that after everything else works; as it stands, this shows when the firmware gets up & running after a reset.

    In Configuration_adv.h, lengthen the motor-off time and set the motor currents:

    #define DEFAULT_STEPPER_DEACTIVE_TIME 600
    #define DIGIPOT_MOTOR_CURRENT {185,215,185,185,135}
    

    The Configuration.h file still has most of the tweaks:

    #define STRING_CONFIG_H_AUTHOR "(Ed Nisley - KE4ZNU - Hotrod M2)"
    #define STRING_SPLASH_LINE2 STRING_VERSION_CONFIG_H
    
    #define BAUDRATE 115200
    
    #define MOTHERBOARD BOARD_RAMBO
    
    #define TEMP_SENSOR_0 1
    #define TEMP_SENSOR_BED 1
    
    #define HEATER_0_MAXTEMP 290
    #define HEATER_1_MAXTEMP 290
    #define HEATER_2_MAXTEMP 290
    #define HEATER_3_MAXTEMP 290
    
    #define X_MAX_POS 136
    #define X_MIN_POS -100
    #define Y_MAX_POS 125
    #define Y_MIN_POS -127
    #define Z_MAX_POS 175
    #define Z_MIN_POS 0
    
    #define HOMING_FEEDRATE {75*60, 75*60, 30*60, 0}
    
    #define DEFAULT_AXIS_STEPS_PER_UNIT   {88.88,88.88,400,424.4}
    #define DEFAULT_MAX_FEEDRATE          {450, 450, 100, 94}
    #define DEFAULT_MAX_ACCELERATION      {5000,2500,2000,10000}
    
    #define DEFAULT_ACCELERATION          10000
    #define DEFAULT_RETRACT_ACCELERATION  10000
      
    

    I missed the max & min position settings on the first pass (they’re new!), which matter because I put the origin in the middle of the platform, rather than the front-left corner. Marlin now clips coordinates outside that region, so the first thinwall calibration box only had lines in Quadrant 1…

  • Bookleting a PDF with Landscape Pages

    For reasons not relevant here, we had to make a booklet out of a PDF file that contained several wide tables that should print in landscape mode, but were tagged as portrait pages. As a further complication, the pdftops utility I normally use complained vociferously about nearly every page:

    Syntax Warning: FoFiType1::parse a line has more than 255 characters, we don't support this
    

    A bit of fiddling produced this recipe, with pdf2ps in place of the usual pdftops:

    pdfcrop --margins "36 0 10 0" FileName.pdf 
    pdftk FileName-crop.pdf rotate 41-46east output FileName-crop-rotate.pdf
    pdf2ps -dLanguageLevel=3 -sPAPERSIZE=letter -dFIXEDMEDIA FileName-crop-rotate.pdf FileName-crop-rotate.ps
    ps2book.pl -f 1 FileName-crop-rotate.ps
    ps2pdf FileName-crop-rotate_book.ps
    

    The gymnastics in pdf2ps forces letter-size pages, no matter what the internal size specifies.

    That was not particularly obvious, but hooray for pdftk…

  • ID3 Tagging Audio Book Files

    For whatever reason, the audio books we get at the library sale generally don’t have CDDB database entries, so I fill in the appropriate values by hand. Weirdly, some individual CDs within a single book do have entries, which confuses the process (well, me) no end unless I notice it first; I’ve turned off auto-lookup to make that problem Go Away. Perhaps a different database would help, but I don’t do this nearly often enough to care that much.

    Given that:

    • Mary plays the tracks sequentially from start to finish
    • The tracks don’t correspond to book divisions
    • She doesn’t care about the details

    I concluded a simple track naming convention that sorts in ascending alphabetic order would suffice.

    Asunder auto-fills the fields after the first CD. After a bit of manual wrestling to extract an error-filled track, I had a directory full of MP3 files with informative, albeit slightly redundant, names:

    1901-01 - Track 01.mp3

    Alas, the ID3 fields apply to a single music CD, with track numbers and names within a single album and no notion of a multi-CD set. I use the “year” field as a CD sequence number; it must be a four-digit year and, seeing as how Asunder defaults to 1900, the first CD becomes 1901.

    So the following fields apply:

    • Genre: “Audio Book” (for v2 tags) or Speech (v1 tag = 101)
    • Artist: author
    • Album: book title
    • Year: 19 + CD number within set as 1901
    • Track Name = CD number + track number as “D:01 T:01”

    But the real gotcha is that the Most Favorite MP3 Player (remember MP3 players?) recognizes only ID3 v1 tags and Asunder writes only ID3 v2 tags.

    Fortunately, the id3v2 utility can do this thing. Rather than screw around selecting each file, extracting the v2 tags, doing something horrible involving bash or sed or awk or whatever, and ramming the results into v1 tags, I just fed in the appropriate number of CDs and more than enough tracks, then ignored any errors concerning missing files.

    Firing a Bash cannon broadside:

    for d in {01..15} ; do id3v2 -1 -a "Who Wrote It" -A "The Book Title" -y 19$d -g Speech 19${d}* ; done
    for d in {01..15} ; do for t in {01..15} ; do id3v2 -1 -t "D:${d} T:$t" -T $t 19${d}-${t}* ; done ; done
    for d in {01..15} ; do for t in {01..15} ; do id3v2 -2 -t "D:${d} T:$t" -T $t 19${d}-${t}* ; done ; done
    

    The last line tightens up the title name tag in v2 format to fit the MP3 player’s teeny display. The next time around, I should remove the “Track” text from the file name for consistency.

    And then it just worked…

  • CD Ripping: Fractional Tracks

    Mary gets books-on-CD at the annual library book sale, but she’s found they’re easier to use in MP3 format. We regard format transformation for our own use as covered by the First Sale Doctrine and Fair Use, but, obviously, various legal opinions differ.

    I use Asunder to rip audio CDs, although it doesn’t handle non-recoverable errors very well at all. Wiping the offending disc with nose oil or ripping from a different drive will resolve most of the issues, but a recent acquisition had a nasty circumferential scratch in the middle of Track 7 that just didn’t respond to Black Magic.

    CDparanoia can rip portions of a track, so a little binary search action extracts the usable data from Track 7:

    cdparanoia "7-7[4:35]" Track7a.wav
    cdparanoia III release 10.2 (September 11, 2008)
    
    Ripping from sector  177155 (track  7 [0:00.00])
    	  to sector  197780 (track  7 [4:35.00])
    
    outputting to Track7a.wav
    
     (== PROGRESS == [                              | 197780 00 ] == :^D * ==)   
    
    Done.
    
    cdparanoia "7[5:30]-7" Track7b.wav
    cdparanoia III release 10.2 (September 11, 2008)
    
    Ripping from sector  201905 (track  7 [5:30.00])
    	  to sector  208894 (track  7 [7:03.14])
    
    outputting to Track7b.wav
    
     (== PROGRESS == [                              | 208894 00 ] == :^D * ==)   
    
    Done.
    

    With that in hand, you import the two WAV files into Audacity with a five second gap between them, drop two seconds of A-440 sine wave in the gap, and export to MP3.

    The M3U playlist entry has the track time in seconds, so I hand-carved that entry to match the abbreviated length:

    #EXTINF:376,Disc 14 Track 7
    14-07 - Track 7.mp3
    

    Done!

  • Thunderbird: Disabling an ISP Email Account

    For reasons that probably make sense to them, Optimum Online (the ISP part of Cablevision) uses totally insecure password-in-the-clear user authentication to the POP3 and SMTP servers. That’s marginally OK for access through their own cable network, but, should you access those servers through a different ISP, you’ve just exposed some sensitive bits to the Internet at large.

    Disabling an account in Evolution requires removing one checkmark:

    Edit → Preferences → Mail Accounts tab → uncheck the account → done!

    Doing the same in Thunderbird, however, requires arcane knowledge and deft surgery, documented in the usual obscure forum post containing most of the information required to pull it off:

    Edit → Preferences → Advanced tab → Config Editor button

    Search for server.server and find the .name entry corresponding to the ISP account. Note the digit identifying the server, which in my case was 1: server1.

    Search for server1 and find the number of the mail.account.* entry with that string in the value field. In my case, that was account1.

    Search for accountmanager to find the mail.accountmanager.accounts entry and remove the account you found from the Value string.

    Done!

    Make a note of all that information, because you must un-futz the accountmanager string to re-enable the account. Of course, if you add or remove any accounts before that, all bets are off.

    There, now, wasn’t that fun?