Com Port with mscomm32.ocx

frytach
Member Posts: 8
Need help with reading data (Barcodescanner) from a com port. I'm using the mscomm32.ocx. (Navision 370)
Example:
//init
MSComm.CommPort(4); //COM4
MSComm.Settings('9600,N,8,1'); //Parameter
MSComm.InputLen(0); //Sofort senden
MSComm.InBufferCount(0); //Init
MSComm.InputMode(0); //Textmode
MSComm.PortOpen(TRUE); //öffnen
//Read????
Result := MSComm.Input();
Doesn't work.
I tried the nfcomm.ocx before. Doesn't work either.
I have no experience with com port programming an would be thankful for any help (hints or examples).
The barcodescanner is working fine. No problems with hyperterminal.
Example:
//init
MSComm.CommPort(4); //COM4
MSComm.Settings('9600,N,8,1'); //Parameter
MSComm.InputLen(0); //Sofort senden
MSComm.InBufferCount(0); //Init
MSComm.InputMode(0); //Textmode
MSComm.PortOpen(TRUE); //öffnen
//Read????
Result := MSComm.Input();
Doesn't work.
I tried the nfcomm.ocx before. Doesn't work either.
I have no experience with com port programming an would be thankful for any help (hints or examples).
The barcodescanner is working fine. No problems with hyperterminal.
0
Comments
-
I never used this way of communication with Barcode scanner. I created own external application, which take the data send from COM port and send them as keystroke to system. Or it work as Automation, which can read the data from scanner and signal that new data arrived is passed to NAV through sending one hotkey and catching that hotkey through menuitem with hotkey in NAV (I had no time to create working event in the automation).
It means that primary function of the aplication is to use COM scanner as Keyboard scanner...0 -
Hi, maybe it's possible to run in a loop and wait for an result of the scanner with a timeout or a max loop counter. But my try wasn't successful.
Has someone written an OCX or Automation for this case. Or is there any existing codeexample for the nfcomm.ocx? My try with nfcomm.ocx looks like this:
//init
CLEAR(ComPort);
ComPort.ComX := 3; //com4
ComPort.BaudRate := 6; //9600bps;
ComPort.Parity := 0; //None
ComPort.DataBits := 4; //8 databits
ComPort.DtrDsr := FALSE;
ComPort.RtsCts := FALSE;
ComPort.XonXoff := FALSE;
ComPort.StopBits := 0; //1 Stopbit
ComPort.SaveParam;
Result := ComPort.ReceiveStr;0 -
As we can't use an event driven method using the mscomm32 directly, the next best thing is to use the Navision Timer automation controller (with events) and poll the InBufferCount
In terms of initializing the mscomm32 control, you should be ok to leave most properties at their default values.
However, you may find you need to play about with the following in order to get it working with your particular device/scenario:
.InBufferSize
.OutBufferSize
.Settings
I found the following settings worked in my particular case:CommCtrl.InBufferSize := 1024; CommCtrl.OutBufferSize := 512; CommCtrl.Settings = '9600,n,8,1';
Open the COM port to communication:CommCtrl.CommPort := 1; CommCtrl.RThreshold := 1; CommCtrl.InputLen := 1; CommCtrl.PortOpen := TRUE;
The code within the Timer event may look something like thisIF CommCtrl.InBufferCount > 0 THEN BEGIN CommCtrl.RThreshold := 0; // Switch off receive event Buffer := CommCtrl.Input; END; CommCtrl.RThreshold := 1; // Switch on receive event
0 -
=D> Super, so funktioniert es. Danke0
-
[Topic moved from 'NAV/Navision' forum to 'NAV Tips & Tricks' forum]Regards,Alain Krikilion
No PM,please use the forum. || May the <SOLVED>-attribute be in your title!0 -
Thanks very much for that great entry.0
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