Closed kzmKZuzmo closed 7 months ago
Hi @kzmKZuzmo Did you get anything related to printing with windows?
Thanks in advance
Up!!
Does there is any solution?
Would allow using cheaper printing devices, such as Epson : TM-T88IV TM-T20III
most of the pos are using USB connection with their printer. supporting USB is a must
this is how to send the comand to the printer to print your lable
for windows File('\computer-name\printerName').writeAsBytes(bytes);
for Linux File(printPort).writeAsBytes(bytes);
make this on your device
Identify the USB device: Use tools like lsusb or dmesg to identify the USB device and find its vendor and product IDs. For example, if you run lsusb, you'll get a list of connected USB devices with their IDs.
lsusb Alternatively, check the kernel log using dmesg:
dmesg | grep USB Find the device node: Once you have identified the USB device, find its associated device node under the /dev directory. This node might be named something like /dev/ttyUSB0, /dev/sdX, or similar.
Set permissions (if needed): Depending on your use case, you might need to set the correct permissions on the device node to allow access. You can use the chmod command for this purpose.
sudo chmod 666 /dev/ttyUSB0 Be cautious with permissions, and only grant the necessary access to users or groups.
Persistent naming with udev: If you want to ensure that a USB device always gets the same port name, you can create a udev rule. Udev rules are stored in the /etc/udev/rules.d/ directory. Create a new rule file, for example, 99-usb-serial.rules:
sudo nano /etc/udev/rules.d/99-usb-serial.rules Add a rule based on the device's attributes. For example:
SUBSYSTEM=="tty", ATTRS{idVendor}=="1234", ATTRS{idProduct}=="5678", SYMLINK+="my_usb_device" Replace 1234 and 5678 with the actual vendor and product IDs of your device. The SYMLINK creates a symbolic link with a custom name (my_usb_device in this case).
After creating the rule, reload udev rules:
sudo udevadm control --reload-rules Now, whenever the specified USB device is connected, it should have a consistent and custom-named port under /dev. Adjust the udev rule and other settings according to your specific requirements and device characteristics.
and dart code (flutter) .env PRINT_PORT=/dev/usb/my_usb_device
import 'package:esc_pos_utils_plus/esc_pos_utils.dart'; import 'package:flutter/material.dart'; import 'dart:io';
...
String printPort = dotenv.env['PRINT_PORT'].toString();
Future
List
bytes += generator.cut();
if(Platform.isLinux){
File(printPort).writeAsBytes(bytes);
}
} }
Hi @kzmKZuzmo, Thank you for providing this complete guideline. I havent tried it yet but wonder if these preliminary steps can be tackled using dart the same way that bluetooth device recognition is handled ?
How about identifying the device using : https://pub.dev/packages/quick_usb Or even https://github.com/woodemi/libusb.dart/blob/master/example/listDeviceProducts.dart
?
Is there a way to print over usb cabel based on windows and linux app ?