interfacing with USB barcode scanner NOT as keyboard

Doug Easterbrook doug at artsman.com
Sun Jun 14 13:10:57 EDT 2020


absolutely.

whatever technologies you use (even a mixture of such)….    the key is the ‘worker’ design pattern.


python could be the initiator (or listener), as could omnis


one of the reasons we have chosen to use postgres listen notify is very pragmatic and related to firewalls and IT people.

to explain.

if our application cannot talk to the database, it cannot run.   Sort of makes sense.   how can you login, or read. data, or update tables without database access.

ergo, the ONLY guaranteed service that we know will be running and will not be blocked by IT people, or firewalls is port 5432 to the database.   IT, or windows defender, or Microsoft, or OSX could put a block on HTTP or FTP, or any myriad of ports for reasons unknown to us.    (and trust me, they’ve all happened).

rather than have to try to tell people to open ports 443 (for http) 5432 for database (53 for NTP) ,etc … we do as much as we can through the database.


other examples

if we want to send an email on a client workstations, we write it to the database and one server is responsible for relaying it.
if we want a bunch of records processed, or omnis reports run on a report server, we write a record to the database.

and then we may have automatic triggers in the database that fire listen/notify., or we send a manual listen notify….




one connection to cure them all.



hope that helps.  very pragmatic notion.








Doug Easterbrook
Arts Management Systems Ltd.
mailto:doug at artsman.com
http://www.artsman.com
Phone (403) 650-1978

> On June 14, 2020, at 8:39 AM, Ben Butler <760.f563 at gmail.com> wrote:
> 
> Hi Doug,
> 
> Neat!  Building on the idea, for people not using Postgress. Do an Omnis
> OW3 HTTP call that is received by a python process that runs a one of the
> many HTTP server implementations that recieves a connection from omnis on a
> web socket. Python can process messgaes received on the socket and send
> response messages. Python also uses std libraries to connect to either
> Rabbit MQ as a consumer or producer, or could connect to Redis and
> subscribe to a specific key.  You replicate the approach on the bar code
> client which reads the scans and sends the message either via the DB and
> uses their pub / sub implementation or by using a MQ technology such as
> rabbit mq. I would not use Kafka as that has a max message payload size of
> 1mb but could be used in the context of  bar code string.  The project I am
> working on is all about a REST client / OW3 worker implementation to
> integrate to local or remote python code which provides a bridge into other
> things such as the above two. Or even using python libraries to create
> graphs from data sent to it from Omnis and returning the bytes of the PNG
> to extend the in built graph capabilities in Omnis.  Basically extending
> anything Python can do such as SciPi/Pandas or AI stuff  and making it
> avaialable back to Omnis. The server side of the HTTP call can be local or
> remote.
> 
> The notify / listen feature in postgress is good to learn about as another
> approach for implementing messaging and interfacing into other things.
> 
> Kind Regards
> 
> Ben
> 
> On Sun, 14 Jun 2020, 15:36 Doug Easterbrook, <doug at artsman.com> wrote:
> 
>> hi Andrew/Marc
>> 
>> I’ve had some offline suggestions for Marc and I thought I’d share the
>> gist of what we can be done with the forum.  We have used this technique
>> for what might be a similar need.   Sohort of developing an xcomp that
>> could be built like a background worker that fires a timer, this can be
>> done today.
>> 
>> OW3 workers and the dams all support background workers whose prime intent
>> in life is to fire a timer thread in omnis that executes a call back, then
>> doing the same for USB input should be possible.   a scan happens, timer
>> fires, data delivered to the application timer.
>> 
>> thats the elegant solution.  Background threads using timers in xcomps are
>> a documented type of process
>> 
>> 
>> 
>> in the absence of an xcomp, how can you do it with two copies of omnis -
>> today (Assuming you are using postgres - which I believe Marc is)
>> 
>> 
>> Omnis copy #1
>> 
>> on the machine is opened to a window and all it does is respond to scans.
>> The scanner is programmed to send a CR after the scan, which invokes the
>> omnis  ‘evafter’
>> 
>> In the ‘eveafter’ code, it fires off a postgres notify with the bar code
>> as part of the message
>> 
>> 
>> Omnis copy #2
>> 
>> the user is doing their thing.     it is set to ‘listen’ for certain
>> messages in the course of whatever the user is doing.
>> 
>> the omnis $listen is executed on a background thread and fires off the
>> timer, which calls an omnis process.
>> 
>> 
>> that way the primary copy of the application (Omnis copy #2) gets notified
>> of the barcode scanner activity  in a very timely manner.  (i.e.within
>> milliseconds)
>> 
>> 
>> 
>> 
>> Listen notify is using the timer threads I spoke about —it is  just not in
>> an xcomp which may (or may not) be easy to write and dedicated specifically
>> to the task.   I know that Kelly Burgess has a USBTalk external — I don’t
>> think he’s written it to accomplish placing something in the timer stack.
>> 
>> 
>> 
>> 
>> so, there’s two options, both of them work.         One is pure ‘out of
>> the box' omnis, the other needs C coding.
>> 
>> 
>> and interesting to note that techniques re exactly the same in both
>> cases.    Using worker threads to accomplish the notifications.
>> 
>> 
>> 
>> how cool is that :)
>> 
>> 
>> 
>> 
>> 
>> 
>> Doug Easterbrook
>> Arts Management Systems Ltd.
>> mailto:doug at artsman.com
>> http://www.artsman.com
>> Phone (403) 650-1978
>> 
>>> On June 14, 2020, at 4:55 AM, Andrew McVeigh <omnis at surfway.com.au>
>> wrote:
>>> 
>>> We connect to a barcode scanner but it IS as a keyboard wedge
>>> 
>>> How else would you read from it without it delivering you the numbers
>> from the barcode?
>>> 
>>> Andrew McVeigh
>>> Surfway Real Solutions
>>> Phone 02 44412679 Mobile 0418428016
>>> www.surfway.com.au
>>> www.berrarabeach.com.au
>>> 
>>> 
>>> <http://www.surfway.com.au/>
>>> <http://www.surfway.com.au/>
>>>> On 13 Jun 2020, at 3:13 am, Marc De Roover <omnis1 at arcict.com> wrote:
>>>> 
>>>> Hello,
>>>> 
>>>> Anybody any experience reading data from a connected USB barcode
>> scanner which is NOT acting as a keyboard ?
>>>> 
>>>> We need it for MacOS.
>>>> 
>>>> Thanks in advance,
>>>> 
>>>> 
>>>> 
>>>> Marc
>>>> _____________________________________________________________
>>>> Manage your list subscriptions at http://lists.omnis-dev.com
>>>> Start a new message -> mailto:omnisdev-en at lists.omnis-dev.com
>>> 
>>> _____________________________________________________________
>>> Manage your list subscriptions at http://lists.omnis-dev.com
>>> Start a new message -> mailto:omnisdev-en at lists.omnis-dev.com
>> 
>> _____________________________________________________________
>> Manage your list subscriptions at http://lists.omnis-dev.com
>> Start a new message -> mailto:omnisdev-en at lists.omnis-dev.com
>> 
> _____________________________________________________________
> Manage your list subscriptions at http://lists.omnis-dev.com
> Start a new message -> mailto:omnisdev-en at lists.omnis-dev.com



More information about the omnisdev-en mailing list