jpwsutton / instax_api

An Api for the Fujifilm Instax SP-2 printer written in Python
MIT License
136 stars 19 forks source link

No Route To Host // Issue Using Instax-Print On Raspberry Pi2 #13

Open Ennochiantapestry opened 5 years ago

Ennochiantapestry commented 5 years ago

I'm using the Raspberry Pi 2 Model 2 V1.1, I am connected to the instax printer by wifi and my WLAN is configured - i can see this in the Pi wifi at the top right of the screen. I've enabled DHCP like this:

sudo nano /etc/network/interfaces

iface wlan0 inet dhcp

However, when I try to send a print across to the instax from the command line:

sudo instax-print /home/pi/image.jpg

I get the following

--- Instax Printer Python Client---

Connecting to Printer

Followed by this error:

File "/usr/local/lib/python3.4/dist-packages/instax_api-0.6-py3.4.egg/instax/sp2.py", line 44 in connect raise(ConnectionError(reply.data)) instax.exceptions.ConnectionError: [Errno 113] No route to host

Its weird it looks like the Pi's connected (it has an IP and the Instax printer is on wlan0). But as soon as I send the command to print then it looks like the Pi can't connect to the printer. How can I resolve this issue or begin to approach a solution?

Any support with resolving this would be greatly appreciated.

shrewmus commented 5 years ago

Hi, @Ennochiantapestry. I don't know is my case will helpful for you.

I don't spend too much time with network configuration. But within this time I can't get worked configuration on my raspberry, except the case when wifi network has range 192.168.0.xxx, and socket for printer opens only on 192.168.0.251

Ennochiantapestry commented 5 years ago

Thanks @shrewmus. I will try to limit the range of my wifi network to 192.168.0.xxx (specifically 192.168.0.251 for the socket). Can i check which version of raspberry pi you are having success with? Could you email a working version of the sd card so i can test it, please? microresonanceATgmailDOTcom Thanks

shrewmus commented 5 years ago

sorry @Ennochiantapestry right now I haven't raspberry. Try to find how to configure wifi network connection with wpa_supplicant configuration. I've made it in this manner

e.g.: file: /etc/network/interfaces.d

allow-hotplug wlan0 iface wlan0 inet static address 192.168.0.1 netmask 255.255.255.0 gateway 192.168.0.1 wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf

file: /etc/wpa_supplicant/wpa_supplicant.conf:

network={ ssid="ESSID" psk="Your_wifi_password" }

essid - like INSTAX- with number instead psk you may use key_mgmt=NONE Note: this may not work in modern distributives at least it may not works with NetworkManager

jpwsutton commented 5 years ago

I agree with @shrewmus, are you able to ping 192.168.0.251 from your Raspberry Pi when the printer is on and you are connected to it's WiFi network?

v0-llc commented 5 years ago

I'm getting the same error with the SP-2 - [Errno 113] No route to host - except I'm using a Pi 3B. Likewise, wlan0 shows that it's "Associated with INSTAX-xxxxxxxx" and seems to be connected, but when I actually run the command to print I get the connectivity error. I've had no problems printing from Mac OS or Windows.

And per @jpwsutton's suggestion, I'm not able to ping 192.168.0.251 either, despite the appearance that I'm connected to the printer.

It may be worth mentioning that I have printed from this Pi before, so I'm not sure what the problem is. I did update the firmware on the Instax, but I can't say for sure that the problem started happening precisely after the update. But that's the only thing I can think of that changed - otherwise this is a fresh install of Raspbian Stretch.

Any ideas for what to try next? Thanks in advance.

jpwsutton commented 5 years ago

It might be worth checking that your Pi has picked up DHCP, If I remember correctly, the IP address for the printer should also be the gateway IP that's assigned in DHCP. If you need, post the output from ifconfig in this issue and we might be able to help some more.

v0-llc commented 5 years ago

@jpwsutton Thanks for getting back to me so quickly - sorry I didn't do the same. Since my last post I've been doing some more work on this, and have been trying to figure out what question I'm really trying to ask...

I have been able to connect to the Pi more reliably and print, but I'm running into issues when I try to connect to more than one network. Basically, I'm trying to connect the Pi to both the Instax and a WiFi SD card - pull images from the card, process them, then print, but I can't seem to get both to work simultaneously. Maybe worth mentioning that I have gotten the whole stack to work on Windows.

Anyway, I realize at this point that this probably isn't an issue with your API, more likely a Linux networking issue, but any insight you can offer is appreciated. Maybe some kind of manual connection through wpa_supplicant.conf - or something like that?

Thanks again for your time.

partynikko commented 4 years ago

Hi 👋

TLDR; Read this: https://www.raspberrypi.org/forums/viewtopic.php?p=1506297#p1506297_

Just wanted to share my solution to fixing my networking issues that are similar to what you are experiencing.

So I've built a photo booth project using an Instax Share SP2. It's being powered by a Raspberry Pi 4 (running Raspbian) and I encountered big issues quite early regarding connecting to the printer and keeping the connection stable. I rarely got connected and if I managed to do so, I either got disconnected or got the connection timeout or "No route to host". I got so tired of this as my Mac and Windows were working fine and I realised the problem has to do something with the RPi.

After a lot of research I found out that the network driver of the Raspbian distro has some issues that a person has fixed with his own driver. I installed it, rebooted and suddenly I could connected, stay connected and print images reliably. If you are experiencing these issues and want the drivers, see this link at the beginning of this post.

My next challenge was that I had to run 2 WiFis - one for connecting to the printer and one for connecting to the interwebz. I solved this by using a USB dongle with WiFi. Now the issue arose of how to route the traffic depending on what I wanted to do. If no routing is present, we might try to connect to the printer via the interface that is connected to the interwebz, hence it will timeout or "No route to host". I solved this (with the help of a friend with good network skills) by supplying a static IP address to the interface that was connected to the Instax printer with a route and add a route for that interface and address of the printer network.

The static IPv4 I chose was 192.168.37.103 and I supplied the address of the printer (192.168.0.251) as the router to this interface. I then also run the following: $ sudo ip route add 192.168.0.0/24 dev <INTERFACE-NAME>

I could now be connected to the printer and another WiFi at the same time with reliable printing functionality. I ran my photo booth at a conference this weekend with around 150 images printed with the printer during a period of 9 hours. I could even replace the film without turning off nor restarting the printer. It just kept staying connected no matter what and had no hiccups what so ever.

I'd say those are pretty good results for an awesome reverse engineered module. Thanks for the job you've put down into this!

v0-llc commented 4 years ago

@partynikko Thanks for the comprehensive breakdown! Since the time of my last post, we've moved on to a laptop solution, but I could definitely see trying to get the Raspberry Pi to work again at some point. It's great to hear your setup ran reliably for so long as well, since it sounds like we're working on fairly similar projects. If we do move back to the Pi and this solution works for us as well, I'll be sure to check back in. Thanks again, Teddy

jpwsutton commented 4 years ago

Thanks @partynikko! If it's ok with you, I'll add your findings to the Wiki so that others can easily find them. Also, do you have any photos or writeup of your project? I'd love to include it in the readme if you do!

partynikko commented 4 years ago

@v0-llc How's your current project working out? Would be cool to see :)

Thanks @partynikko! If it's ok with you, I'll add your findings to the Wiki so that others can easily find them. Also, do you have any photos or writeup of your project? I'd love to include it in the readme if you do!

Yes of course! I have now received photos of the project where it was displayed. I can make a small writeup this weekend and I'll make a PR together with the photos 👍

v0-llc commented 4 years ago

@partynikko wow I'm late on this...

Actually just launched the project this weekend! - https://1000wordmirrors.com/festival-galleries/okeechobee-2020/

The photographer is a friend of mine. Basically the idea is that when he's out taking pictures on his nice professional camera, he can give people watermarked prints of their pictures. I also included a QR code in the corner so they can scan and jump right to this page and have their picture pop up to purchase prints, etc...

Basically the setup is Camera > Wifi SD card > Read / modify pics on computer with Python script (on laptop) > Print out using Instax API

Seems to be working well so far! Thanks again @jpwsutton for putting this all together.