PDA

View Full Version : How to Read Data From COM Port



hehanhan
05-12-2016, 10:27 AM
Hello masters of VBA,

After spent days search on google for this and failed to understand what exactly what I need to do. I finally decided to post here and ask for some serious help.

I have a USB GPS Data Logger (HOLUX M-215+) is currently connected to my COM8 port with baud=4800 parity=N data=8 stop=1.
What I want to do is that while it is connected to my PC, I want to one click in a userform and then the N&W information in GPS is recorded and send to some specific cell in workbook. The usefrom is working now except GPS part.

I understand there are few diffent versions of codes out there. But, as a beginer of VBA, I dont even know where to put these codes, and how to make VBA reading information via USB GPS. Can someone please walk me through? Your kindness and knowledge is greatly appreciated.



Thank you very much.
Ken

hehanhan
05-13-2016, 08:02 AM
anyone?

hehanhan
05-13-2016, 03:09 PM
I can not delete this post, please delete

jonh
05-13-2016, 03:57 PM
Why delete?
This is quite a specific (not realy VBA related) request that very few people would have experience of.
If the problem is solved post the answer so others can learn.

SamT
05-14-2016, 09:22 AM
Thread moved to Integration forum and Title changed for better response to question

RuralGuy
05-16-2016, 07:04 AM
Maybe this link will help: www dot granite dot ab dot cs slash access slash serialport dot htm
...sorry but it won't let me post a url yet.

hehanhan
05-16-2016, 07:08 AM
Just want to quickly update to people who will need this.
I finally got the code working for me from this site: ..hxxp://dev.emcelettronica.com/serial-port-communication-in-excel-vba

I alter the code to output to a cell within the sheet and manipulate from there. However, I encountered with another problem. the COM Port# changes every time when USB GPS plug into the computer. I will have to manually change the com port#/ is there anyway the code can read USB come port #? Thanks. I know very few people know this.. I am just testing luck here

SamT
05-16-2016, 07:52 AM
Since the device probably has a unique ID: http://answers.microsoft.com/en-us/windows/forum/windows_7-hardware/how-to-programmatically-find-usb-serial-port/3b00a0e3-5d7d-4d6d-9a34-6860f8ce3da0

Reading all open ports: https://www.petri.com/quickly_find_local_open_ports

Once you have a list of open ports, Loop thru them and try to read from each. If you first check a hard coded array of the ports known to be used elsewhere, it will speed things up quite a bit.


Does the device ave a drive letter in Windows Explorer? https://social.msdn.microsoft.com/Forums/en-US/f5788e63-1ab0-4bb3-b052-72a62743b47f/when-sending-a-worksheet-to-the-usb-port-?forum=isvvba

When you finally get the entire process working, please post all the code here.

hehanhan
05-17-2016, 09:21 AM
Hi Sam, I appreciate you reply to my post. Unfortunately, my background is not from IT area. I understand so little for what you referenced. But thank you anyway.