Jump to content

Wikipedia:Reference desk/Archives/Computing/2020 January 13

From Wikipedia, the free encyclopedia
Computing desk
< January 12 << Dec | January | Feb >> January 14 >
Welcome to the Wikipedia Computing Reference Desk Archives
The page you are currently viewing is a transcluded archive page. While you can leave answers for any questions shown below, please ask new questions on one of the current reference desk pages.


January 13[edit]

Tiny Linux-friendly laser printer[edit]

If you look up "Samsung ML-2160" with a search engine you'll find a cool piece of hardware, a super compact laser printer that unfortunately has a craptacular Linux driver situation (binary-only module from Samsung with slowly worsening compatibility with CUPS/foomatic/whatever). Does anyone know of a laser printer (no inkjets please!) that uses a standardized command set (PS, PCL or whatever) instead of a stupid proprietary one, that is in a similar physical small form factor? I do have a fairly small Brother laser printer on another machine, that works well, but it is not as small as the Samsung mentioned. Thanks for any suggestions/recommendations. 2601:648:8202:96B0:C923:B226:7FA3:2DDD (talk) 05:41, 13 January 2020 (UTC)[reply]

The Brother HL-1210W seems to be a similar size ([1]_340 mm x 238 mm x 189 mm) to the Samsung ML-2160 ([2] 331 x 215 x 178mm). But AFAICT the Linux situation is not much better [3] [4] [5] [6] [7] [8] [9] [10]. BTW, I think the 1211W and 1212W are basically the same printer, just releases for different regions so they may be what you find depending on where you live.

You can try using some default generic open source brother driver but it doesn't seem to work well at least as of a few years ago. Alternatively you can using proprietary Brother drivers. [11]. These seem to work well at the moment including on Raspberry Pi's [12] (so I guess there is ARM support). But I guess maybe there is some binary blob hence why no one added more generic support without requiring Brother's proprietary drivers. There's also a chance no one ever bothered since it's not very popular and most people even Linux users don't care that much if it's proprietary if it works and doesn't cause problems. Especially since they probably need to write a spec and get someone to re-write the PPD or whatever to avoid copyright issues. (I hardly ever use Linux so couldn't figure out from the RPM/Deb.) Anyway, how long support will remain, I don't know although at the moment other than Deb or RPM the driver doesn't seem to restrict itself to certain kernel versions.

These may be illustrative of the problem [13] [14] [15] [16] [17]. Such compact printers tend to be also cheap and therefore have low end hardware. To be fair, with most now including network support generally in the form of Wi-Fi, things aren't quite as bad as they were e.g. the 1210W has 32MB. Still the CPU is fairly low speced. Compared to what people had 20 years ago even on high end printers, things aren't that bad so probably they could add PostScript support, but that would require more effort than they're willing to put in especially since I suspect with the advances of both Postscript, and hardware, their modern implementations probably don't work so well on low end hardware.

It seems the Brother 1210W does support PJL [18] but even more so than PCL, that has enough proprietary extensions and caveats that there's no guarantee generic drivers will work very well. So unless someone bothers to adapt the driver to the printer, compatibility may be poor. (To put it a different way, I'm not convinced that SPL is really much worse.) And as mentioned before, I don't think most people care. If it works for them on Linux, the fact it may break in 5 years to 10 years is not something they worry about since they figure they will have a new printer by then. In some countries, e.g. here in NZ, those low end printers can be bought almost free after rebate regularly. (Possibly this was the same for the Samsung printer.) Especially for these low end devices. It's only people in unsupported OSes like *BSD variants, and a small number of advocates who care, and many of them aren't using such low end devices anyway for a variety of reasons.

Incidentally, is there some reason you're still getting drivers from Samsung? HP purchased Samsung's printer division in 2017 [19]. I don't know if they bothered to update the Linux printer driver for this printer, probably not since [20] finds a driver last updated in September 2017 for Debian which was before the acquisition was completed. Still you're much more likely to get something from HP than you are for Samsung. Frankly I'm surprised Samsung is still bothering to provide drivers on their site.

Nil Einne (talk) 08:27, 13 January 2020 (UTC)[reply]

Probably the other thing is that most people who do care about open source etc on Linux, seem to generally prefer HP. [21], [22] HP Linux Imaging and Printing seems to be included on many distros. While some do require plug-ins (binary blobs) [23]) many [24] do not. I mean okay, I'm not quite sure whether Richard Stallman is happy with HP-LIP but it seems even Debian is sort of okay with it [25] [26].

From [27], it seems the M15w is fairly small. The quoted dimensions there are 346mm (W) x 189mm (D) x 159mm (H). You will get some conflicting info on these figures with some saying ~346 x 348 x 280 mm. AFAICT e.g. [28] [29], I think this represents the size when the tray is open with paper in the printer, but AFAIK, the Samsung printer is similar so I assumed when replying above you are referring to the closed dimensions. (I had a quick look and I don't think you can keep paper stores in the Samsung's tray when it's closed, even when not in use, at least not without very short paper, or paper sticking out of the tray and probably getting folded and crushed slightly, as with most printers of that type. Sorry if I'm wrong.)

If you want dimensions with the tray open and paper in it, you may need to visit a store since I'm not sure if that info is generally made clear in specs or reviews, although I'm not seeing anything to suggest the Samsung is particularly stellar in that regard. In fact if you were thinking of that size, you may want to look carefully even at printers not known for being small. I mean okay, not massive MFCs with multiple trays and stuff, but I think some e.g. the Brother HLL2375DW don't really take up that much more space (maybe about 20 - 30 mm width and length), it's just that they have a non retracing tray. Depending somewhat on your paper size.

Anyway the M15w does seem to be supported by the HPLIP without a plug-in per the earlier link ([30]). I think the M15a is the same thing but without the WiFi and I think M14-M17 are again the same printer but for different regions so these will be what you want to look out for. [31].

P.S. I assume the reason for the height increase with the HP dimensions is if you need to open the cover. From videos etc, I don't think this is required in normal use, and although maybe the paper may stick up slightly when coming out, I don't think it does much. But I assume HP doesn't want people complaining if they stick the printer in a tiny hole, then can't lift the cover when the paper gets stuck or they need to replace the toner or whatever. Again, I assume the Samsung is similar.

Nil Einne (talk) 09:13, 13 January 2020 (UTC)[reply]

Thanks, I believe the driver on hp.com these days is the same as the one Samsung used to distribute. I haven't tried it yet due to the bad experiences I've seen some report of. I'll write a little more about that tomorrow as it's late here (California) now and I'm only half awake. It's true that feeding paper into the ML-2160 requires flipping out a tray, and there is also a flip-open cover to receive the output, but when everything is folded up the package is very compact. The issue is that even if you use the binary blobs, the driver is very unreliable and tends to stop after a few pages. If I can get the thing to work from a raspberry pi though, that would be great, I could just dedicate a pi to the printer and just not upgrade the software after that. I'll look at the HLL2375DW too. 2601:648:8202:96B0:0:0:0:DF95 (talk) 10:09, 13 January 2020 (UTC)[reply]
Nil Einne, your link about the Brother HL-1210W is 404 and Newegg sells cartridges for it but not the printer itself. I suspect it uses the same mechanism as the Samsung ML-2160, and may be discontinued. On another computer (not here) I have what I think is a Brother HL-L2350DW,[32] although I'm a little confused since Newegg specs that as being a GDI (Windows) printer but I'm pretty sure it has built-in Postscript emulation. I'll check it when I get a chance. It works well with Linux and though it is bigger than the Samsung, it's still fairly small for a laser printer and its duplex feature is sometimes handy (though it slows down printing by quite a lot). So I might just get another one. The HL-L2375DW appears to be an NZ model. Another idea might be to replace the Samsung with my existing Brother printer, and replace the Brother printer with one that can print in color, a capability I've sometimes wanted. I may ask for advice about color printers in another post at some point. Thanks! 2601:648:8202:96B0:0:0:0:DF95 (talk) 09:49, 14 January 2020 (UTC)[reply]

Notice: fwrite(): write of 8192 bytes failed with errno=22 Invalid argument[edit]

Does anyone know wot this means? It's pointing to an error in this line of code.

$res = fwrite( $pipe, $buffers[$fd], 65536 );

Many thanks, if anyone can help! ——SN54129 17:18, 13 January 2020 (UTC)[reply]

You might get more help if you mentioned which language you are using. "code" could mean anything from assembly right up to SQL. Martin of Sheffield (talk) 17:43, 13 January 2020 (UTC)[reply]
@Martin of Sheffield: Oh. Well, it's in a PHP file, so that? ——SN54129 18:06, 13 January 2020 (UTC)[reply]
By chance, is it running on OSX? 135.84.167.41 (talk) 18:11, 13 January 2020 (UTC)[reply]
If this is Windows, you may need to double-escape all backslashes (or just use normal slashes - PHP converts it for you). 135.84.167.41 (talk) 18:12, 13 January 2020 (UTC)[reply]
No W10—but thanks for the blackslash point, I read something like that elsewhere. But there isn't a slash on that particular line? ——SN54129 18:33, 13 January 2020 (UTC)[reply]
I'm just taking a wild guess, because I don't know this language, but you said that you are writing 8192 bytes, but the statement has a 65536 in it. Often this parameter is the number of bytes to be written. Bubba73 You talkin' to me? 19:02, 13 January 2020 (UTC)[reply]
Have a look at the manual page. @Bubba73: I don't think length is the issue: "If the length argument is given, writing will stop after length bytes have been written or the end of string is reached, whichever comes first". @Serial Number 54129: are you sure that you opened the file as binary? See the note "On systems which differentiate between binary and text files (i.e. Windows) the file must be opened with 'b' included in fopen() mode parameter". If that isn't the answer, try without the 65556; it is an optional argument. The result may be wrong/badly formatted, but it would identify if the third argument as the problem. If it works with two parameters then you need to check up on $pipe, $buffers and $fd. Did you check the status of the fopen()? Martin of Sheffield (talk) 19:34, 13 January 2020 (UTC)[reply]
Errno 22 is EINVAL which on a write() call usually means the address of the write buffer is invalid. I'm suspicious of the $buffers[$fd] parameter. Are you sure that that refers to a valid memory buffer that is at least 65536 bytes long? CodeTalker (talk) 21:24, 13 January 2020 (UTC)[reply]
It's more likely that $pipe is "an object which is unsuitable for writing". Alternatively, if indeed $buffers[$fd] is only 8192 bytes, then write may run of the end of the buffer. Try STDOUT for the file descriptor, or a smaller value for the size to see which one breaks it. --Stephan Schulz (talk) 22:23, 13 January 2020 (UTC)[reply]
@CodeTalker and Stephan Schulz: Remember that the manual quoted above allows for short writes: "writing will stop after length bytes have been written or the end of string is reached, whichever comes first". If $buffers[$fd] does not point to a valid string then there could be an input issue. On the other hand $pipe needs to be valid or the output buffer will not be found. Martin of Sheffield (talk) 22:34, 13 January 2020 (UTC)[reply]
If $pipe were not a writable file descriptor, you would get errno 9 (EBADF) rather than EINVAL. This version of the Linux man page for write(2) says EINVAL can also happen if the "fd is attached to an object which is unsuitable for writing", which I guess is referring to having mmapped a read-only file, or if the file is opened with O_DIRECT and the buffer is misaligned, but hopefully the OP isn't using mmap or O_DIRECT. CodeTalker (talk) 22:56, 13 January 2020 (UTC)[reply]
(1) The OP is using the PHP fwrite() function, the C write function is a good guide, but not infallible. (2) The OP is using Windows 10 so Linux man pages are a good guide, but again not infallible. (3) The PHP man page warns that under Windows the file needs to be opened as a binary file, something not applicable to Linux. Martin of Sheffield (talk) 23:21, 14 January 2020 (UTC)[reply]
That call can give that error code if $buffers[$fd] is not a valid string, or if something went wrong with the underlying write system call (unlikely). 108.29.38.53 (talk) 15:29, 16 January 2020 (UTC)[reply]