Wednesday, 5 March 2025

Warp shell

After watching a Youtube by the very respected Dave on a new command line shell called Warp, I gave its go. After describing a task to be done it built the commands needed for that task and executed them. In this case I asked it to "create a page of thumbnails images from a directory of pictures". As it progressed it provided explanations and checked before running any actual commands. The task was achieved by generating a command script incorporating the subtasks to be done.  The script was left behind and can be adapted and deployed in other similar situations.

Very impressive I can see we will have to explore this tool further. As with a lot of AI products Warp gets you sarted in the right direction and breaks the tyrany of the blank page.

Available on Mac, Windows, Linux from Warp.dev


...........



The script created .. Might need to add .png and parameterise a few things before redeployment

#!/bin/bash


# Create thumbnails directory if it doesn't exist

mkdir -p CEP_Thumbnails


# Remove any existing thumbnails to start fresh

rm -f CEP_Thumbnails/*.jpg CEP_Thumbnails/*.jpeg


# Counter for thumbnails

count=0


# Process all JPG and JPEG files

for img in CEP_AllPics/*.jpg CEP_AllPics/*.jpeg CEP_AllPics/*.JPG CEP_AllPics/*.JPEG; do

    # Check if file exists (to handle case when no matches are found)

    if [ -f "$img" ]; then

        # Extract filename without path

        filename=$(basename "$img")

        echo "Creating thumbnail for $filename"

        

        # Create thumbnail using sips

        sips --resampleWidth 150 "$img" --out "CEP_Thumbnails/$filename"

        

        # Increment counter

        ((count++))

    fi

done


echo "Created $count thumbnails"


# Generate HTML file

cat > thumbnails.html << EOF

<!DOCTYPE html>

<html lang="en">

<head>

    <meta charset="UTF-8">

    <meta name="viewport" content="width=device-width, initial-scale=1.0">

    <title>Image Thumbnails</title>

    <style>

        body {

            font-family: Arial, sans-serif;

            margin: 20px;

            background-color: #f5f5f5;

        }

        h1 {

            text-align: center;

            color: #333;

        }

        .thumbnail-grid {

            display: grid;

            grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));

            gap: 15px;

            padding: 20px;

        }

        .thumbnail-container {

            background: white;

            box-shadow: 0 2px 5px rgba(0,0,0,0.1);

            padding: 10px;

            border-radius: 5px;

            text-align: center;

            transition: transform 0.3s ease;

        }

        .thumbnail-container:hover {

            transform: scale(1.05);

        }

        .thumbnail-container img {

            max-width: 150px;

            max-height: 150px;

            display: block;

            margin: 0 auto 8px auto;

        }

        .thumbnail-container p {

            margin: 5px 0 0 0;

            font-size: 12px;

            color: #666;

            overflow: hidden;

            text-overflow: ellipsis;

            white-space: nowrap;

        }

        .timestamp {

            text-align: center;

            margin-top: 30px;

            color: #777;

            font-size: 14px;

        }

    </style>

</head>

<body>

    <h1>Image Thumbnails</h1>

    <div class="thumbnail-grid">

EOF


# Add each thumbnail to the HTML

for thumb in CEP_Thumbnails/*.jpg CEP_Thumbnails/*.jpeg CEP_Thumbnails/*.JPG CEP_Thumbnails/*.JPEG; do

    if [ -f "$thumb" ]; then

        filename=$(basename "$thumb")

        echo "        <div class=\"thumbnail-container\">" >> thumbnails.html

        echo "            <a href=\"CEP_AllPics/$filename\" target=\"_blank\">" >> thumbnails.html

        echo "                <img src=\"$thumb\" alt=\"$filename\">" >> thumbnails.html

        echo "                <p>$filename</p>" >> thumbnails.html

        echo "            </a>" >> thumbnails.html

        echo "        </div>" >> thumbnails.html

    fi

done


# Close the HTML file

cat >> thumbnails.html << EOF

    </div>

    <div class="timestamp">

        Generated on $(date)

    </div>

</body>

</html>

EOF


echo "HTML gallery created: thumbnails.html"

echo "Open this file in your web browser to view the thumbnails."


# Make the script executable

chmod +x create_thumbnails.sh


Thursday, 20 February 2025

Epson Printer both connected and disconnected at the same time. ( USB version, Windows 10 and testing on a Mac )

Welcome to the next episode of fun at the tech support shop (printer edition).

Epson XPS-355


We have an Epson printer XP–355 of 2018 vintage but has been working fairly reliably on Windows 10 since installed. There have been a couple of times where I've needed to delete and re-add the printer but generally apart form the cost of ink no complaints.


Just recently (Feb 2025) it's been playing up and after some investigation we figured out that it is when the printer goes to "power off sleep" and is woken up again, it fails to fully reconnect and continue to the print service. 


There are so many variables in PC printing infrastructure, drivers, anti-virus software, Windows updates and microcode updates. The set up is using proprietary Epsom printing software. There are three ways of connecting to this printers, direct USB cable, attach via the Wi-Fi from a router or direct to device via air-print.  


This is another one of those really annoying problems where it looks like the physical connection/network connection is maintained and the device is visible but the device is not responding correctly.


After a couple of debug sessions where we have nailed it down to not reattaching after printer power off. I brought the machine back to the "Repair Shop" to give it a try on my fresh windows installation. The intention is to remove all the complexities of somebody else's network and antivirus. I was successful in re-creating the issue .  I did a fresh install of the Epsom Printer support software from the Epsom website (the test computer had never had it before) to make sure that was new original and genuine. There is even a utility called Epsom printer connection checker included as part of the Epson software bundle. After the the full fresh software install and the software updates the printer was connected by USB cable.


At first try the printer and combined scanner worked perfectly. However after a period of time if the printer is switched off using the power switch and back on again, it gets stuck in this very weird state. Curiously restarting the PC print spooler service on the PC issues a "print status page" but then still fails to print and shows as offline in devices. The pictures below show the Epson printer being, in normal state, then the off-line state with the Epsom printer connection checker getting stuck at 5%. The last picture shows again the Epson connection utility still stuck at 5% but the scanner utility working perfectly.


Did I miss any debug steps anywhere? I had a look at the Internet forums and they're littered with printers not reconnecting over Wi-Fi or being dropped and the usual mish-mash of "This is what worked for me to get it going again". What we found was that only a reboot of the of the PC would bring it back again. Sometimes removing and re-adding the printer will allow for rediscovery and for the printer to work again but not consistently. It's been very consistent that this falling asleep because of energy saving or switch off/on causes this half connected state. 


Is the printer just too old knackered? It seems a strange way for it to fail ? Or could this be to do with a recent windows update which both mine and antique shop have done ?


Just for grins I tryied the same process on an older Macintosh computer to see if the problem can be located to the actual printer or the windows driver and if the direct to device via Air-print has the same failure to reconnect issue. 


.

Normal state

After printer self switch off and or again … Status is offline and utility is stuck at 5% for hours...


After power off and on connections get stuck


But the scanner utility still works over the same USB connection at at the same the time printer connection checker is stuck - AARGH


In the bad state for printing but still works as a scanner down the same connection wire


Testing from a Mac laptop

Initially connecting the XPS-355 printer the "Printer and scanner" control panel setting said that there was no driver available for the device but then the printer just showed up in the devices using the Air-print direct to device connection mode. Both printing and scanning works well and the device is correctly identified. Doing the printer power off and back on test the printer reappeared as idle then printed correctly.  The Mac uses a service called Bonjour that locates devices on a connection path by name. If a storage server or printer moves Bonjour will locate and re-attach by name. This may explain why the Mac was successful in relocating the printer.

After downloading the official Epson software for the rather older MacOS 10.13.8 High Sierra allows us to try with the Official Epson driver software on the Mac. The printer can be seen over the USB as well as the previous Air-print mode. More options are available including "Bidirectional communication" which is on by default.

On the Mac during the specific printer "idle sleep", when awakened by a print request, communication was reestablished after about 20 seconds and printing completed. However the "power cycle off/on" resulted in a permanent disconnection.

Which type of idleness is breaking the device ?

Upon reviewing the printer setup mode it can be seen that there is a sleep timer and a power off timer.
These were adjusted to 10 and 30 minutes to increase the cycle time of testing.


Printer idle sleep, works as expected

Printer Power off sleep ( the one that causes the trouble)


Getting closer to another view of the issue ( maybe )

Continuing testing on the Mac we see that reawakening after the printer has put it self to idle type sleep the printer works as expected; sending a print wakes the printer. However allowing the printer to do the longer full power off triggers the same "Disconnected" issue once the printer is switched back on again. Captured in this video here we see the misleading system printer status showing the printer offline but the Epson Printer utility shows as Ready. 

Unlike the PC when sending a print to the printer it does work but the printer, after a short in use goes back to Offline.

Check out the video ... This appears to be the exact same issue as seen on the PC except that the Mac managed to print the document. 


However unlike the PC which could still drive the scanner function of the device, on the Mac,  the Epson scan utility just hangs trying to connect to the re-powered device. 



Work around for Printer Power sleep

We have concluded that the "power off sleep" and awakening with resulting failure to reconnect is the cause of the persistent offline status and failure to connect for further prints and scans on both Mac and PC.

Mitigation can be found (on the Mac anyway) by unplugging and replugging the USB cable that switches the printer status to idle, allowing printing to continue, however the scan utility still hangs.

It would seem that setting the "Power off sleep" time to "OFF" is the only mitigation to ensure continuous printer and scanner connection at the expense of power saving. The printer can be switched off when the PC is rebooted and not switch on until printing is needed.



Another Printer



Turns out I have an EPSON Stylus Photo PX730WD in the loft that can be dellopyed for further testing. After plugging this more upscale printer in it was detected and a software update was found. After a bit of a delay it printed the test text and performed the scanning function. The printer was specifically identified by type which is always a good sign. 
With this printer the "Power off" setting shortest time is 2 hours. 

Testing the power of switch off/on gave predictable and correct results with the printer returning to full service after power cycling.

Just go get another new printer

I don't think we really won with the printer this time - whilst we have identified the problem and it’s parameters - we can’t find any way to fix it.

Given the cost of a new printer  £60- £80 and the propriety ink about the same  (cheaper inks are available) it hardly seems worth it to dig even deeper.  This is modern electronics 99% can work fine but just one tiny little bug knackers the service.


A selection of replacement printers ( Dalek not included )

We will be sure to throughly test the sleep and power on/off modes for the new device.

Gritty printer details 

This via system report on the Mac