dcsimg


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 3 of 3

Thread: "using kernel32 to read serial port into Excel" Reloaded

  1. #1
    Join Date
    Nov 2008
    Posts
    2

    "using kernel32 to read serial port into Excel" Reloaded

    Hi,
    I need to write data to the serial port using VBA in Excel, but I need to do it using API and not any third party controls like MSCOMM.

    I am not an expert programmer (I am actually a hardware engineer) but I have a fairly good ideea of programming in various environments (I am "literate"). So I had to look at what others did before me.

    I am using the attached code, which is an adaptation (actually a simplification) after some code that has been discussed in another thread on this forum, few months ago. The thread is called "using kernel32 to read serial port into Excel" and the code is in the attached text file.

    What I need it to do, is that at the press of a button, some string would be sent to the serial port. The code I attached actually runs, without any compilations or runtime errors. However, it does not really send anything to the port. I know this, because a) I have a device attached to the serial port and it does not receive any message and b) I monitor the TX line with an oscilloscope.

    What I can say is that the operation of opening the port is successful. Normally, when the port is not open the TX line would be at about 10V which means a logic 0. When I perform the open port operation (the "CreateFile" line of code), I can see the line going to -10V which is a logic 1, and which is the dominant state of the bus; so far so good. But when I perform the "WriteFile" operation, which in my understanding is the one that actually sends the data to the port, I do not see the TX line toggling. It just stays at a logic 1. When I perform the CloseHandle (hCommHandle) operation, the TX line goes back to 0 logic, so the port is closed.

    I am a little confused, because the WriteFile operation actually returns a value of "1", which would indicate no error occurs...

    What am I doing wrong?

    Thank you in advance for your help!

    Regards,
    Cristian
    Attached Files Attached Files

  2. #2
    Join Date
    Apr 2007
    Location
    Sterling Heights, Michigan
    Posts
    8,663
    Quote Originally Posted by brumbarchris View Post
    I need to write data to the serial port using VBA in Excel, but I need to do it using API and not any third party controls like MSCOMM.
    Those are pretty rigid conditions. Why do you need to go this route when using it would make your life so much easier.

    Also, MSComm is NOT a third party control. It is a Microsoft control that ships with the development platform.

  3. #3
    Join Date
    Nov 2008
    Posts
    2

    Re: "using kernel32 to read serial port into Excel" Reloaded

    Hi,
    Thanks for the reply.
    I am aware that MSCOMM is not really third party. But I need an application that will work on ANY fresh WinXP installation. And an application using MSCOMM will not fulfill that goal.

    The app will be deployed in many places without anybody to maintain the PCs or adjust them. I just need a simple file to be distributed with a memory stick.

    So... any idea why the code does not work?

    Regards,
    Cristian

Similar Threads

  1. using kernel32 to read serial port into Excel
    By zerugamat in forum VB Classic
    Replies: 11
    Last Post: 01-12-2010, 06:34 PM
  2. Read Com serial port into Excel
    By aak2008 in forum VB Classic
    Replies: 3
    Last Post: 10-19-2008, 05:20 PM
  3. Replies: 1
    Last Post: 02-21-2006, 02:23 AM
  4. Replies: 0
    Last Post: 11-11-2005, 11:59 AM
  5. Read Serial Port
    By Al Guten in forum .NET
    Replies: 3
    Last Post: 06-22-2002, 01:37 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center