Pages: 1 [2]   Go Down
Author Topic: Using C++ for USB interfacing  (Read 3413 times)
0 Members and 1 Guest are viewing this topic.
Seattle, WA USA
Online Online
Brattain Member
*****
Karma: 644
Posts: 50487
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Try using the fully qualified name:
System.IO.Ports.SerialPort ^mySerialPort = gcnew System.IO.Ports.SerialPort(...)
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 15
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hmm, I've changed it to the full name

Code:
void CzebraDlg::OnBnClickedButton5()
{
            //SerialPort *mySerialPort = gcnew SerialPort("COM4");
      System.IO.Ports.SerialPort ^mySerialPort = gcnew System.IO.Ports.SerialPort("COM4");
       try
                  {
                        
                  
                  if (mySerialPort->IsOpen)
                        {
                              mySerialPort->Close();
                        }
                  //mySerialPort->PortName = "COM4"// + IDC_EDIT2->Text;
                  mySerialPort->Open();
                  }
            catch (Exception ^ex)
                  {
                  CerrorDlg  cid;  //*** Create an instance of our dialog
                  cid.DoModal(); //Display Dialog box
                  }      
}

But now the errors are different,

[glow]1>.\zebraDlg.cpp(1693) : error C2882: 'System' : illegal use of namespace identifier in expression
1>.\zebraDlg.cpp(1693) : error C2228: left of '.IO' must have class/struct/union
1>.\zebraDlg.cpp(1693) : error C2228: left of '.Ports' must have class/struct/union
1>.\zebraDlg.cpp(1693) : error C2228: left of '.SerialPort' must have class/struct/union
1>.\zebraDlg.cpp(1693) : error C2065: 'mySerialPort' : undeclared identifier
1>.\zebraDlg.cpp(1693) : error C2061: syntax error : identifier 'System'[/glow]
1>.\zebraDlg.cpp(1698) : error C2227: left of '->IsOpen' must point to class/struct/union/generic type
1>        type is ''unknown-type''
1>.\zebraDlg.cpp(1700) : error C2227: left of '->Close' must point to class/struct/union/generic type
1>        type is ''unknown-type''
1>.\zebraDlg.cpp(1703) : error C2227: left of '->Open' must point to class/struct/union/generic type
1>        type is ''unknown-type''

Maybe I missed using a namespace? Here are the ones I'm using

Code:
#using <System.dll>
#include "stdafx.h"
#include "zebra.h"
#include "zebraDlg.h"
#include <string>
#include <fstream>
#include "windows.h"
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include "usb.h"
#include <setupapi.h>
#include <hidsdi.h>
using namespace System;
using namespace System::IO;
using namespace System::Threading;
Logged

Seattle, WA USA
Online Online
Brattain Member
*****
Karma: 644
Posts: 50487
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Are you using Visual Studio to create/edit this application? If so, which version? If not, what are you using?
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 15
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Yup, its Visual Studio, its the 2005 version
Logged

Seattle, WA USA
Online Online
Brattain Member
*****
Karma: 644
Posts: 50487
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

PM me, and send me your code, please (zip up the whole solution directory). I'll see if I can figure out why your getting these errors.
Logged

Pages: 1 [2]   Go Up
Jump to: