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

Cash drawer is opening constantly #95

Closed
yongmin86k opened this issue Mar 15, 2023 · 3 comments
Closed

Cash drawer is opening constantly #95

yongmin86k opened this issue Mar 15, 2023 · 3 comments
Assignees
Labels
Platform: ios Target: stario10 Issues related to the API and other StarIO10 library.

Comments

@yongmin86k
Copy link

Description

Our customer reported the issue with the cash drawer that opens constantly.

The log for this issue shows that the printer command is sending Action.Open too many times.

We are not sure how this happened for only this specific store while there are 3000 users.

Printer commands are logged as followings:

{
	"title": "StarXpandCommand",
	"version": "1.0.0",
	"contents": [
		{
			"category": "Document",
			"contents": [
				{
					"category": "Drawer",
					"contents": [
						{"method": "Action.Open", "parameter": {"channel": "No.1", "on_time": 200}},
						{"method": "Action.Open", "parameter": {"channel": "No.1", "on_time": 200}},
						{"method": "Action.Open", "parameter": {"channel": "No.1", "on_time": 200}},
						{"method": "Action.Open", "parameter": {"channel": "No.1", "on_time": 200}},
						{"method": "Action.Open", "parameter": {"channel": "No.1", "on_time": 200}},
						{"method": "Action.Open", "parameter": {"channel": "No.1", "on_time": 200}},
						{"method": "Action.Open", "parameter": {"channel": "No.1", "on_time": 200}},
						{"method": "Action.Open", "parameter": {"channel": "No.1", "on_time": 200}},
						{"method": "Action.Open", "parameter": {"channel": "No.1", "on_time": 200}},
						{"method": "Action.Open", "parameter": {"channel": "No.1", "on_time": 200}},
						{"method": "Action.Open", "parameter": {"channel": "No.1", "on_time": 200}},
						{"method": "Action.Open", "parameter": {"channel": "No.1", "on_time": 200}},
						{"method": "Action.Open", "parameter": {"channel": "No.1", "on_time": 200}},
						{"method": "Action.Open", "parameter": {"channel": "No.1", "on_time": 200}},
						{"method": "Action.Open", "parameter": {"channel": "No.1", "on_time": 200}},
						{"method": "Action.Open", "parameter": {"channel": "No.1", "on_time": 200}},
						{"method": "Action.Open", "parameter": {"channel": "No.1", "on_time": 200}},
						{"method": "Action.Open", "parameter": {"channel": "No.1", "on_time": 200}},
						{"method": "Action.Open", "parameter": {"channel": "No.1", "on_time": 200}},
						{"method": "Action.Open", "parameter": {"channel": "No.1", "on_time": 200}},
						{"method": "Action.Open", "parameter": {"channel": "No.1", "on_time": 200}},
						{"method": "Action.Open", "parameter": {"channel": "No.1", "on_time": 200}},
						{"method": "Action.Open", "parameter": {"channel": "No.1", "on_time": 200}},
						{"method": "Action.Open", "parameter": {"channel": "No.1", "on_time": 200}},
						{"method": "Action.Open", "parameter": {"channel": "No.1", "on_time": 200}},
						{"method": "Action.Open", "parameter": {"channel": "No.1", "on_time": 200}}
					]
				},
				{
					"category": "Drawer",
					"contents": [
						{"method": "Action.Open", "parameter": {"channel": "No.1", "on_time": 200}},
						...
					]
				},
				{
					"category": "Drawer",
					"contents": [
						{"method": "Action.Open", "parameter": {"channel": "No.1", "on_time": 200}},
						...
					]
				}
			]
		}
	]
}

Your device where the bug occurs

  • Device: iPad12, 1(j181AP)
  • OS: iPadOS
  • Version: iOS 15.1

Your printer

  • Model Names: mC-Print3
  • Firmware Version: 3.6
  • Interface: Ethernet

Your development environment

n/a

To Reproduce

Can't replicate

Expected behavior

Should create a command once for the cash drawer

Screenshots

image

Additional context

n/a

@yongmin86k yongmin86k added the Status: triage Start out by looking at issues label Mar 15, 2023
@bandit-ibayashi
Copy link
Member

@yongmin86k Is it possible to share the code of the part that generates print data with StarXpandCommand.StarXpandCommandBuilder() etc.?

This json format data can be obtained by the following, but we would like to know what the part that generates it is.
var commands = await builder.getCommands();

@bandit-ibayashi bandit-ibayashi added Status: question Further information is requested and removed Status: triage Start out by looking at issues labels Mar 16, 2023
@bandit-ibayashi bandit-ibayashi self-assigned this Mar 16, 2023
@yongmin86k
Copy link
Author

The json format for the command is stated in previous comment. - #95 (comment)

And this is the code for opening the cash drawer. Most users don't see the issue but it only happened to 1 user and I suspect the culprit is their network speed.

// settings are configured as a user select on the discovered printer
const settings = new StarConnectionSettings()
const printer = new StarPrinter(settings)

const builder = new StarXpandCommand.StarXpandCommandBuilder()
const document = new StarXpandCommand.DocumentBuilder()
const cashDrawer = new StarXpandCommand.DrawerBuilder()
const openParameter = new StarXpandCommand.Drawer.OpenParameter()

cashDrawer.actionOpen(openParameter)
document.addDrawer(cashDrawer)
builder.addDocument(document)

try {
  const commands = await builder.getCommands()

  await printer.open()
  await printer.print(commands)
} catch {
// we capture the any errors with Sentry
} finally {
  await printer.close()
  await printer.dispose()
}

@bandit-ibayashi bandit-ibayashi removed the Status: question Further information is requested label Mar 23, 2023
@bandit-ibayashi
Copy link
Member

@yongmin86k Thank you for sharing your code to open the drawer and the information on how often this issue occurs.

I used your code to generate a command in json format but I was not able to reproduce this issue. It generated a code that opens only once. The frequency of occurrence also suggests that it is not caused by the SDK or our library, but by other factors.

{
    "title": "StarXpandCommand",
    "version": "1.0.0",
    "contents": [
        {
            "category": "Document",
            "contents": [
                {
                    "category": "Drawer",
                    "contents": [
                        {
                            "method": "Action.Open",
                            "parameter": {
                                "channel": "No.1",
                                "on_time": 200
                            }
                        }
                    ]
                }
            ]
        }
    ]
}

For reference, here is the implementation. We have applied your code to our print sample.

private _onPressPrintButton = async() => {
    const settings = new StarConnectionSettings();
    settings.interfaceType = this.state.interfaceType;
    settings.identifier = this.state.identifier;

    const printer = new StarPrinter(settings);

    const builder = new StarXpandCommand.StarXpandCommandBuilder()
    const document = new StarXpandCommand.DocumentBuilder()
    const cashDrawer = new StarXpandCommand.DrawerBuilder() 
    const openParameter = new StarXpandCommand.Drawer.OpenParameter()

    cashDrawer.actionOpen(openParameter)
    document.addDrawer(cashDrawer)
    builder.addDocument(document)

    try {
        var commands = await builder.getCommands();
        console.log(`commands¥n${commands}`);

        await printer.open();
        await printer.print(commands);

        console.log(`Success`);
    }
    catch(error) {
        console.log(`Error: ${String(error)}`);
    }
    finally {
        await printer.close();
        await printer.dispose();
    }
}

@bandit-ibayashi bandit-ibayashi added Status: help wanted Extra attention is needed Platform: ios Target: stario10 Issues related to the API and other StarIO10 library. labels Apr 25, 2023
@bandit-ibayashi bandit-ibayashi closed this as not planned Won't fix, can't repro, duplicate, stale Aug 30, 2024
@bandit-ibayashi bandit-ibayashi removed the Status: help wanted Extra attention is needed label Aug 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Platform: ios Target: stario10 Issues related to the API and other StarIO10 library.
Projects
None yet
Development

No branches or pull requests

2 participants