Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Classic Chat / Problem with fast text entry into EditBox or GetTextInput using a Barcode Scanner

Author
Message
Rudders
12
Years of Service
User Offline
Joined: 20th Jan 2012
Location: Oxfordshire UK
Posted: 16th Apr 2013 14:00
Hi all,

I am using a Barcode scanner to enter numbers into an EditBox. The numbers being scanned are all 6 digits long (I will be scanning a variety of barcode lengths, but for now the barcodes are all 6 numbers). About 1 in 6 scans results in a single digit being missed so that only 5 numbers appear in the EditBox, the number being missed varies even with the same barcode being scanned several times a different number will be missed! The follow are the results of scanning a single barcode with the number 101308:

101308
11308
11308
101308
101308
101308
101308
11308
101308
101308
101308
101308
101308
11308
101308
101308
01308
101308

I have had numbers in the middle and at the end of a code missing.

I have the same issue with the StartTextEntry command.

Is this a speed issue that AppGameKit inputting has a fault with?

Any ideas please, this is stopping from me progressing any further!

Many Thansk
Markus
Valued Member
20
Years of Service
User Offline
Joined: 10th Apr 2004
Location: Germany
Posted: 16th Apr 2013 14:25
hmm, you can try set the text, read and compare the text
and if different set again until its correct as workaround.
between a set text is a sync? i think true.
baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 16th Apr 2013 14:40
That's a pretty good suggestion. If you know you are expecting six digits and will always expect six digits then keep scanning until you get it. I'd be surprised if there are any barcode scanners that don't work this way.


this.mess = abs(sin(times#))
Markus
Valued Member
20
Years of Service
User Offline
Joined: 10th Apr 2004
Location: Germany
Posted: 16th Apr 2013 15:08 Edited at: 16th Apr 2013 15:12
what happens if you log this scans in a file too, are they all correct? i wrote because baud rate.
Rudders
12
Years of Service
User Offline
Joined: 20th Jan 2012
Location: Oxfordshire UK
Posted: 16th Apr 2013 15:24
Yes, I forgot to mention that when scanned into Notepad there is no problem whatsoever, all scans are correct. The fault lies with AppGameKit?

In the finished app I will not know how long the barcode will be.
Markus
Valued Member
20
Years of Service
User Offline
Joined: 10th Apr 2004
Location: Germany
Posted: 16th Apr 2013 16:28 Edited at: 16th Apr 2013 16:31
it is possible that the scanner send a cr lf (13 10) with at end
and you can see the barcodes in notepad one underneath the other?
maybe is the box in agk confused with a multiline string.
Rudders
12
Years of Service
User Offline
Joined: 20th Jan 2012
Location: Oxfordshire UK
Posted: 16th Apr 2013 16:45
Yes the scanner is send CR LF and each barcode is listed correctly one under the other in Notepad, so I assume this is an AppGameKit issue?
baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 16th Apr 2013 17:05
How does the data transfer from the scanner to AppGameKit?


this.mess = abs(sin(times#))
Markus
Valued Member
20
Years of Service
User Offline
Joined: 10th Apr 2004
Location: Germany
Posted: 16th Apr 2013 17:11
what happens if you cut the 13 10 and set the editbox text,
or `do you already cut it from barcode?
Rudders
12
Years of Service
User Offline
Joined: 20th Jan 2012
Location: Oxfordshire UK
Posted: 16th Apr 2013 17:29
Just using the barcode scanner as is, with the CR LF to change the editbox focus, the problem is that the numbewrs are not being read into the editbox or textentry correctly.
AgentSam
12
Years of Service
User Offline
Joined: 14th Mar 2012
Location: Virtual Space
Posted: 16th Apr 2013 18:40
Rudders,

Here's a quick suggestion - try disabling frame rate limiting, at least for the duration of the input loop, by using SetSyncRate(999,0) or SetVSync(0).

Why? Because the keyboard input speed is still propably being limited by the keyboard polling, which occurs only once per frame, in AGK.

Let us know if that makes a difference... I'll do some testing of my own later today.

Cheers,
AgentSam
Markus
Valued Member
20
Years of Service
User Offline
Joined: 10th Apr 2004
Location: Germany
Posted: 16th Apr 2013 19:02
@Rudders ahh,ok,i understand,sorry.
Markus
Valued Member
20
Years of Service
User Offline
Joined: 10th Apr 2004
Location: Germany
Posted: 16th Apr 2013 19:57 Edited at: 16th Apr 2013 19:58
did you try what happens with SetEditBoxMultiLine( index, multiline ) ?
maybe alternative read the key state self and put the text in the
editbox if possible.
Rudders
12
Years of Service
User Offline
Joined: 20th Jan 2012
Location: Oxfordshire UK
Posted: 17th Apr 2013 12:29
ABSOLUTELY FANTASTIC! Thank you very much for the SetSyncRate advice it now works perfectly no matter how fast I scan the barcodes.

SetSyncRate(90,0) works fine on all tests, Is there any reason why this should not be set permanently for my App?

Many thanks
AgentSam
12
Years of Service
User Offline
Joined: 14th Mar 2012
Location: Virtual Space
Posted: 17th Apr 2013 18:53
You're welcome, Rudders.

No, there's no reason why you shouldn't set up the required sync rate for your entire app, like you say.

However - I should warn you to keep in mind the following:
* Your app may work correctly on some devices.
* Your app will NOT work correctly on some less powerful devices.

The less powerful devices will keep losing characters during input, no matter what you set the sync rate to, if the keyboard input rate (characters per second) is higher than the apps frame rate...

This is due to the way AppGameKit polls the keyboard once per frame, instead of using a message queue to respond to the events. So, I'm afraid doing your barcode reader app in AppGameKit isn't a 100% reliable solution. You will, inevitably, need some barcode input validation checks - if you intend to keep your customers happy and use the app in a retail environment. (I know this isn't good news for you, but there it is.)

Perhaps Paul could reimplement some of the input handling (especially keyboard input) in AppGameKit to be event based?

Cheers,
AgentSam
Paul Johnston
TGC Developer
21
Years of Service
User Offline
Joined: 16th Nov 2002
Location: United Kingdom
Posted: 18th Apr 2013 02:42
That raises and interesting bug. As Agent Sam correctly pointed out it is limited by the sync rate, if two keys are pressed within the same frame then only the most recent will be detected, but at 60fps they would have to be pressed within 17 milliseconds of each other. 90fps will get you down to 11 milliseconds. No PC will have problems running up to hundreds of frames per second but mobile devices are limited to 60fps.

Rewriting the input system would be a lot of work for this special case, but I'll bear it in mind if I find myself working on it.
Rudders
12
Years of Service
User Offline
Joined: 20th Jan 2012
Location: Oxfordshire UK
Posted: 18th Apr 2013 11:26
Interesting stuff guys, thanks. I guess for now I will have to test the App on specific devices and only recommend these to my clients.

Thanks for all you input, it has allowed me to move on with the project..

For interest I have attached a picture of the Stock Take part of my App...

Cheers Rudders

Attachments

Login to view attachments
baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 18th Apr 2013 11:29
Looks great Rudders


this.mess = abs(sin(times#))
Ancient Lady
Valued Member
20
Years of Service
User Offline
Joined: 17th Mar 2004
Location: Anchorage, Alaska, USA
Posted: 18th Apr 2013 16:49
Very nice looking app.

Cheers,
Ancient Lady
AGK Community Tester and AppGameKit Master

Login to post a reply

Server time is: 2024-05-01 20:48:56
Your offset time is: 2024-05-01 20:48:56