tr3v3r / react-native-esc-pos-printer

An unofficial React Native library for printing on an EPSON TM printer with the Epson ePOS SDK for iOS and Epson ePOS SDK for Android
MIT License
164 stars 71 forks source link

hey all, I came across this repo while trying a few things on my Epson printers but i'm having trouble connecting to either of my printers (1 Lan and 1 USB) using this latest version `4.0.0-beta.6` #146

Closed tr3v3r closed 4 months ago

tr3v3r commented 4 months ago
          hey all, I came across this repo while trying a few things on my Epson printers but i'm having trouble connecting to either of my printers (1 Lan and 1 USB) using this latest version `4.0.0-beta.6`

I'm just trying the example provided but i keep getting an Error Printer is not initialized. Please call init() first.

I've tried running printerInstance.init() before the queueTaks but no luck either. Any ideas why i might be getting this?

Thanks!


export const printSimpleReceipt = async (target, deviceName) => {
    try {
      const printerInstance = new Printer({
        target: target,
        deviceName: deviceName,
      })

      await printerInstance.addQueueTask(async () => {
        await Printer.tryToConnectUntil(
          printerInstance,
          (status) => status.online.statusCode === PrinterConstants.TRUE
        );

        await printerInstance.addText('Hello world!');
        await printerInstance.addFeedLine();
        await printerInstance.addCut();
        await printerInstance.sendData();

        await printerInstance.disconnect();
      })

    } catch (e) {
      throw e
  }
}

Originally posted by @omarst9 in https://github.com/tr3v3r/react-native-esc-pos-printer/issues/139#issuecomment-2100644061

tr3v3r commented 4 months ago

Please specify printer model you're using

omarst9 commented 4 months ago

@tr3v3r the USB printer is TM-T88v and the LAN is TM-T82II

tr3v3r commented 4 months ago

@omarst9 before printing have you used printer discover?

If it possible post the target and device name you're passing to Printer class

omarst9 commented 4 months ago

Yes, I was using printer discover. I confirmed the target and deviceName were both correct

   const printerInstance = new Printer({
      target: "USB:/dev/bus/usb/002/002",
      deviceName: "TM-T88V",
    });

I got it to work now after I rebuilt the app. I had the 3.0.2 version installed before i updated to 4.0.6 so that was most likely the reason.