How To Read Com Port

bablo
Member Posts: 43
I want to connect a scanner to my system and read the data from the port where the scanner is attached.
0
Comments
-
Best is to create Automation for that. Or you can use the "Microsoft Communications Control, version 6.0" OCX (without triggers), you cannot create code "when scanner read something, run this trigger). For this you need MSCOMM32.OCX. I will try to upload my application changing COM scanner into Keyboard scanner and with interface to NAV to be able to read data from the scanner.0
-
I worked for 2 projects where scanners were involved. One used the com port automation as kine noted and one used a usb port sending the data direct to the keyboard buffer. Acutally it does not matter wheter you are using com or usb.
What I want to say is: Its maybe possible to just have the cursor blinking on the field you want and then do your scan ==> Data is written to the field without fuss. Maybe nonsense, but just to think about it.
Thomas0 -
kine wrote:Best is to create Automation for that. Or you can use the "Microsoft Communications Control, version 6.0" OCX (without triggers), you cannot create code "when scanner read something, run this trigger). For this you need MSCOMM32.OCX. I will try to upload my application changing COM scanner into Keyboard scanner and with interface to NAV to be able to read data from the scanner.0
-
ta5 wrote:I worked for 2 projects where scanners were involved. One used the com port automation as kine noted and one used a usb port sending the data direct to the keyboard buffer. Acutally it does not matter wheter you are using com or usb.
What I want to say is: Its maybe possible to just have the cursor blinking on the field you want and then do your scan ==> Data is written to the field without fuss. Maybe nonsense, but just to think about it.
Thomas0 -
What type of code?
Thomas0 -
Sorry, cant send you the automation object, since I have developed it for my last company I worked for.
What excactly do you want to do with the scanner?0 -
ta5 wrote:Sorry, cant send you the automation object, since I have developed it for my last company I worked for.
What excactly do you want to do with the scanner?0 -
Can you configure your scanner to have the data from the scanner right to the keyboard buffer. If yes you don't have to fiddle with com port functions.0
-
I am not allowed to upload my whole application, but it is easy to create one application or Automation for that (if you are using serial port scanner). Just create new application/automation, use the SerialPort component in VisualStudio 2005, use somewhere this code:
//sPort1 - System.IO.Ports.SerialPort //EmulateKeyb - flag if keyboard emulation is enabled String Data = sPort1.ReadLine(); Data = Data.Replace("\r", ""); IWshRuntimeLibrary.WshShellClass Shell = new IWshRuntimeLibrary.WshShellClass(); bool bWait = false; object Wait = bWait; if (EmulateKeyb) { Shell.SendKeys(Data, ref Wait); } else { LastData = Data; Shell.SendKeys("^{F12}", ref Wait); //Ctrl+F12 }
this code will send the data as keyboard keys if emulation is enabled, else it will store the data into buffer and send Ctrl+F12 into keyboart input. Than it is easy to catch this key on your form (through hidden menu button with one item with this shortcut) and call the function to read the buffer (assume Automation and not just simple application).
Of course you need to configure and open the port first, but it is easy and I know that you will not have problems with that.0 -
kine wrote:I am not allowed to upload my whole application, but it is easy to create one application or Automation for that (if you are using serial port scanner). Just create new application/automation, use the SerialPort component in VisualStudio 2005, use somewhere this code:
//sPort1 - System.IO.Ports.SerialPort //EmulateKeyb - flag if keyboard emulation is enabled String Data = sPort1.ReadLine(); Data = Data.Replace("\r", ""); IWshRuntimeLibrary.WshShellClass Shell = new IWshRuntimeLibrary.WshShellClass(); bool bWait = false; object Wait = bWait; if (EmulateKeyb) { Shell.SendKeys(Data, ref Wait); } else { LastData = Data; Shell.SendKeys("^{F12}", ref Wait); //Ctrl+F12 }
this code will send the data as keyboard keys if emulation is enabled, else it will store the data into buffer and send Ctrl+F12 into keyboart input. Than it is easy to catch this key on your form (through hidden menu button with one item with this shortcut) and call the function to read the buffer (assume Automation and not just simple application).
Of course you need to configure and open the port first, but it is easy and I know that you will not have problems with that.0 -
-
It is written over the port on the case of your PC... if you mean if it is 1 or 2...0
-
Hi Kine
Maybe a stupid question, but to ask again:
Why not configure the scanner in a way so the scanner is writing the code directly to the keyboard buffer :?
Thomas0 -
Yes, you can, but if the scanner is connected to COM, you need some driver or application on the PC which will do that. And if you do not have such a driver with the scanner, there is no way and you need to create your own one... :-) Scanner as a HW is not able do it without SW support...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