Receive data from barcode scanner by ethernet (not handheld)

MAOF
Member Posts: 4
Hello everyone,
this is my first message in the forum.
I need some help... I need to receive data from a barcode scanner by his ethernet port. It's a Datalogic DS2400N.
The scanner reads a barcode every few seconds/minutes and I need Navision to wait for each data...
I've been searching in a lot of barcode post around then forum and I tried to do this with ComCom but there’s no way to receive data.
My code...
I don't know if this is enough or I need to do something else.... I run the codeunit but I don't receive any message when the scanner reads a barcode.
Is ComCom the correct option or do I need another??.... ADCS, Business Notification Server, NAS (actually I use NAS for other things),...
I'm a bit lost...
Can someone please help me????
Thanks a lot!!!
this is my first message in the forum.
I need some help... I need to receive data from a barcode scanner by his ethernet port. It's a Datalogic DS2400N.
The scanner reads a barcode every few seconds/minutes and I need Navision to wait for each data...
I've been searching in a lot of barcode post around then forum and I tried to do this with ComCom but there’s no way to receive data.
My code...
OnRun() IF ISCLEAR(ComCom) THEN IF NOT CREATE(ComCom) THEN ERROR('Error al crear Comunication Component...'); IF ISCLEAR(SBA) THEN IF NOT CREATE(SBA) THEN ERROR('Error al crear Socket Bus Adapter...'); ComCom.AddBusAdapter(SBA, 0); SBA.OpenSocket(51238,'191.0.1.61'); // The ip address/port of the barcode scanner... // When I run the codeunit I see this message... MESSAGE('Socket abierto 191.0.1.61:51238');
ComCom::MessageReceived@1(VAR InMessage:Automation "''.IDISPATCH") MESSAGE('Mensaje recibido...'); InMsg:= InMessage; inS:= InMsg.GetStream(); WHILE NOT inS.EOS DO BEGIN inS.READ(ltEtiqueta); MESSAGE(ltEtiqueta); END; InMsg.CommitMessage();
I don't know if this is enough or I need to do something else.... I run the codeunit but I don't receive any message when the scanner reads a barcode.
Is ComCom the correct option or do I need another??.... ADCS, Business Notification Server, NAS (actually I use NAS for other things),...
I'm a bit lost...

Can someone please help me????
Thanks a lot!!!
0
Answers
-
Don't know anything about ComCom, but the event in the codeunit can only fire as long as the codeunit is runing, so you need a loop inside it. Is this the case? "I run the codeunit" is a bit unclear.0
-
Thanks for your answer AK!!
"I run the codeunit" means I push Run button once and there is no loop inside.
I thought was enough to execute OnRun code once, because ComCom would be waiting to the event, but it seems I was wrong...
If I use a loop, the second time I try to open the socket I get an error...
Can you show me a little bit example???
Thank you.0 -
ComCom::MessageReceived is an event fired by the ComCom2 component. The ComCom2 automation must be loaded into the client memory to be able to fire events.
Your codeunit simple opens the connections and quits, leaving the connection open (connection is owned by NAV process) but without the actual receiver of your message once codeunit the execution finishes. Next time you try runing your codeunit the port number is already taken by open (and orphaned) connection.
What you need to do is to mark the codeunit as a Single Instance. Once run it will be kept in client's memory for as long as the client process lives. Each message send remote peer will fire the ComCom::MessageReceived
Remember that the NAV code is not re-entrant. If a message comes while the code is executed the event might be fired returning control to the ComCom::MessageReceived function leaving the system unstable. This usually ends, sooner or later, with the client crash.
If you have any means to disable / pause remote peer while received message is processed use it, if not make the event handler short and fast - for example write and commit a single record with received data to a buffer table and leave it to be processed by another client/nas session
Slawek
Slawek Guzek
Dynamics NAV, MS SQL Server, Wherescape RED;
PRINCE2 Practitioner - License GR657010572SG
GDPR Certified Data Protection Officer - PECB License DPCDPO1025070-2018-030 -
Thank you Slawek!!
What do you mean to load ComCom2 into the client memory? How can I do that...?
The codeunit is mark as a Single instance.
The ComCom Automation::'Navision Communication Component version 2'.CommunicationComponent, is mark WithEvents = Yes.
So I can't understand why it doesn't work...
I've tried with Hyperterminal and receive the data from de scanner by the ip/port so I don't know what happen.
Any suggest??
0 -
What do you mean to load ComCom2 into the client memory? How can I do that...?
It needs to be declared as global variable, otherwise it will only exists when the function where it has been declared is executed (even if it is a local var in OnRun trigger).
Slawek Guzek
Dynamics NAV, MS SQL Server, Wherescape RED;
PRINCE2 Practitioner - License GR657010572SG
GDPR Certified Data Protection Officer - PECB License DPCDPO1025070-2018-030 -
At the first post you can see my code and the instruction
CREATE(ComCom)
And Yes, the variable is declare as a global.
Every minute, the scanner reads four or five labels.... So I can´t understand why this readings doesn't fire the event ComCom::MessageReceived.
Please help.... I believe I'm very near to get the solve but it must miss some detail...0 -
At the first post you can see my code and the instruction
CREATE(ComCom)
In your case all looks good.
Try setting ReceiveTimeout property on SBA components.
Slawek Guzek
Dynamics NAV, MS SQL Server, Wherescape RED;
PRINCE2 Practitioner - License GR657010572SG
GDPR Certified Data Protection Officer - PECB License DPCDPO1025070-2018-030
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions