Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

StarIOExtManager print not working #41

Open
khaledwj90 opened this issue Jul 11, 2019 · 1 comment
Open

StarIOExtManager print not working #41

khaledwj90 opened this issue Jul 11, 2019 · 1 comment

Comments

@khaledwj90
Copy link

I'm not able to print it says invalid port name check my code below:

`printInvoice = async () => {
try {
var connect = await StarPRNT.connect('BT:00:12:F3:3A:66:1B', 'StarPRNT', true);
console.log(connect); // Printer Connected!
} catch (e) {
console.error(e);
}

    let commands = [];
    commands.push({
        append:
            "Star Clothing Boutique\n" +
            "123 Star Road\n" +
            "City, State 12345\n" +
            "\n"
    });
    commands.push({appendCutPaper: StarPRNT.CutPaperAction.PartialCutWithFeed});

    try {
        var printResult = await StarPRNT.print('StarPRNT', commands);
        console.log(printResult); // Success!
    } catch (e) {
        console.error(e);
    }
};`

however, it gives below error:

Printer Connected ExceptionsManager.js:82 Error: Invalid port name. at createErrorFromErrorData (NativeModules.js:155) at NativeModules.js:104 at MessageQueue.__invokeCallback (MessageQueue.js:414) at MessageQueue.js:127 at MessageQueue.__guard (MessageQueue.js:314) at MessageQueue.invokeCallbackAndReturnFlushedQueue (MessageQueue.js:126) at debuggerWorker.js:80

@hunwalk
Copy link

hunwalk commented Jul 24, 2019

Try the followings:

Option 1:

Make sure that the port is exactly the port of the device, and you're connected to it.
Always try to connect dynamically, do not hardcode the port inside the connection script.

Option 1.5:

Use another emulation. If you're using mPop StarPRNT is fine but raster printers like the TSP100 and many others are using StarGraphics. (however bad emulation shouldnt throw this error, but it's worth a try)

Option 2:

I've encountered a strange bug a while ago. I don't know if it has been fixed or not, but when you use connect and print together, IOS does not ask for the port inside the print function however android did, even if it was connected. Solution:

if (Platform.OS === 'ios') {
  var printResult = yield StarPRNT.print(data.printer.emulation, data.printer.commands)
}else{
  var printResult = yield StarPRNT.print(data.printer.emulation, data.printer.commands, data.printer.portName)
}

keep in mind, that I'm using a generator function because of redux-saga, so don't freak out when you see the yield keyword, just use await

Option 3:

Disconnect your barcode scanner, and do not use connect, just try to freefall print with:

var printResult = yield StarPRNT.print(data.printer.emulation, data.printer.commands, data.printer.portName)

If you want to get the status of the printer once in a while, just connect listen for hardware events, then disconnect. I used to get invalid port name myself sometimes, i solved it with try-catching and reconnecting, it usually works, and reporting back connection errors to my server but i did not get constant data.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants