I need help communicating with a serial device using MsComm32.ocx
MsCom.InBufferSize := 1024;
MsCom.OutBufferSize := 512;
MsCom.Settings('9600,n,8,1');
MsCom.CommPort:=8;
MsCom.PortOpen(TRUE);
MsCom.RThreshold := 1;
TimeOutCount := 100;
REPEAT
SLEEP (1000);
TimeOutCount -= 1;
UNTIL (MsCom.InBufferCount >= 1) OR (TimeOutCount <= 0);
That is what I currently have to trigger the rest of the code. However, it does not seem to register the input at the moment.
The device in question is a PSC handheld Scanner. The scanner functionality sends a string through the serial port, and awaits a response (another string) then passes yet another string back containing the data.
Any help/tips/advice at all would be greatly appreciated!
Edit: The problem was with the setup of the comport. Because the device was using an RS232 port, a COM port could not just be opened. As we have created a solution through VB, I don't know the specifics, but there are a series of settings that use GUID's to set the COM port before it can be interfaced. This, apparently, would be possible in NAV.
Answers
MVP - Dynamics NAV
My BLOG
NAVERTICA a.s.
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:
Open the COM port to communication:
The code within the Timer event may look something like this
www.NextEqualZero.com
A technical eye on Dynamics NAV
Thank you very much for the response
However, I had already searched the forums and read that response, it's the InBufferCount I'm having issues with. It doesn't seem to be triggered when the handheld sends an output
MVP - Dynamics NAV
My BLOG
NAVERTICA a.s.
The scanner is using a different companys software, which we can't get access too. Therefore it cannot be modified. However, NAV doesn't seem to pick up any data from it at all. I do currently have a colleague writing an interface for it in VB, but it would be nice if I knew where I was going wrong really!
Why not configure the scanner in order to send scanned data to the keyboard buffer? This way, the scanner works exactly as when the data would have been entered by keyboards.
Regards
Thomas
It would be ideal, but I have to work with the current handheld spec, can't modify the handheld software!