Qt-interest Archive, March 2002
qextserialport - problem
Message 1 in thread
Dear Wayne Roth.
I try to use the qextserialport classes to add serial communication to my
application.
I get this compiler error:
win_qextserialport.cpp(156) : error C2664: 'CreateFileW' : cannot convert
parameter 1 from 'char [81]' to 'const unsigned short *'
Types pointed to are unrelated; conversion requires
reinterpret_cast, C-style cast or function-style cast
NMAKE : fatal error U1077: 'cl' : return code '0x2'
What is the problem??
This is my .pro file:
TEMPLATE = app
CONFIG += qt warn_on debug
DEFINES += _TTY_WIN_
HEADERS = qextserialbase.h \
win_qextserialport.h \
posix_qextserialport.h \
qextserialport.h
SOURCES += main.cpp \
qextserialbase.cpp \
win_qextserialport.cpp \
posix_qextserialport.cpp \
qextserialport.cpp
INTERFACES += repeaterdialogwidget.ui
TARGET = reptest
I use qt3.0.3 enterprise on Win2k, and qextserial ver 0.6, downloaded it
today from your site.
Sincerely,
Erlend
Message 2 in thread
> win_qextserialport.cpp(156) : error C2664: 'CreateFileW' : cannot convert
> parameter 1 from 'char [81]' to 'const unsigned short *'
> Types pointed to are unrelated; conversion requires
> reinterpret_cast, C-style cast or function-style cast
> NMAKE : fatal error U1077: 'cl' : return code '0x2'
In win_qextserialport.cpp change CreateFile to CreateFileA
or (if you don't fear side effects, I got none so far)
undef UNICODE in /qt/mkspecs/win32-msvc/qmake.conf and
run qmake for your project again.
M.
Message 3 in thread
Hi,
CreateFileW is the unicode version of CreateFile.
The solution is to make sure that you application is
unicode compliant, and to define character arrays
at TCHAR (as I recall). TCHAR is a define that
translates into char or wchar depending on if
unicode is enabled.
George Huber
Computer Scientist
SRI, International
phone: 732-427-8064
fax : 732-427-2065
cell : 732-740-4018
george.huber@mail1.monmouth.army.mil
-----Original Message-----
From: Erlend Helmersen [mailto:eh@poseidon.no]
Sent: Thursday, March 21, 2002 7:15 AM
To: wroth@speakeasy.org
Cc: QT
Subject: qextserialport - problem
Dear Wayne Roth.
I try to use the qextserialport classes to add serial communication to my
application.
I get this compiler error:
win_qextserialport.cpp(156) : error C2664: 'CreateFileW' : cannot convert
parameter 1 from 'char [81]' to 'const unsigned short *'
Types pointed to are unrelated; conversion requires
reinterpret_cast, C-style cast or function-style cast
NMAKE : fatal error U1077: 'cl' : return code '0x2'
What is the problem??
This is my .pro file:
TEMPLATE = app
CONFIG += qt warn_on debug
DEFINES += _TTY_WIN_
HEADERS = qextserialbase.h \
win_qextserialport.h \
posix_qextserialport.h \
qextserialport.h
SOURCES += main.cpp \
qextserialbase.cpp \
win_qextserialport.cpp \
posix_qextserialport.cpp \
qextserialport.cpp
INTERFACES += repeaterdialogwidget.ui
TARGET = reptest
I use qt3.0.3 enterprise on Win2k, and qextserial ver 0.6, downloaded it
today from your site.
Sincerely,
Erlend
--
[ signature omitted ]
Message 4 in thread
Dear George, thank you for your reply...
I am no expert in windows programming, and this i a class library that
I hoped to use out of the box...
The actual function call is the one below:
Win_Handle=CreateFile(portName, GENERIC_READ|GENERIC_WRITE,
FILE_SHARE_READ|FILE_SHARE_WRITE, NULL,
OPEN_EXISTING, 0, NULL);
where portName is a char array. The definition of CreateFile takes a char
pointer
as its first argument, but it seems that for some reason CreateFileW is
called,
why?? Is it something with my setup, or what....
As I said, this is a class library qextserialport that I hoped to use as is,
but if I have to debug it too much, i will rather implement something simple
myself.
Erlend
> -----Original Message-----
> From: owner-qt-interest@trolltech.com
> [mailto:owner-qt-interest@trolltech.com]On Behalf Of Huber, George CECOM
> RDEC STCD SRI
> Sent: Thursday, March 21, 2002 15:50
> To: 'eh@poseidon.no'; wroth@speakeasy.org
> Cc: QT
> Subject: RE: qextserialport - problem
>
>
> Hi,
>
> CreateFileW is the unicode version of CreateFile.
> The solution is to make sure that you application is
> unicode compliant, and to define character arrays
> at TCHAR (as I recall). TCHAR is a define that
> translates into char or wchar depending on if
> unicode is enabled.
>
> George Huber
> Computer Scientist
> SRI, International
> phone: 732-427-8064
> fax : 732-427-2065
> cell : 732-740-4018
> george.huber@mail1.monmouth.army.mil
>
>
> -----Original Message-----
> From: Erlend Helmersen [mailto:eh@poseidon.no]
> Sent: Thursday, March 21, 2002 7:15 AM
> To: wroth@speakeasy.org
> Cc: QT
> Subject: qextserialport - problem
>
>
> Dear Wayne Roth.
>
> I try to use the qextserialport classes to add serial communication to my
> application.
> I get this compiler error:
>
> win_qextserialport.cpp(156) : error C2664: 'CreateFileW' : cannot convert
> parameter 1 from 'char [81]' to 'const unsigned short *'
> Types pointed to are unrelated; conversion requires
> reinterpret_cast, C-style cast or function-style cast
> NMAKE : fatal error U1077: 'cl' : return code '0x2'
>
> What is the problem??
>
> This is my .pro file:
> TEMPLATE = app
> CONFIG += qt warn_on debug
> DEFINES += _TTY_WIN_
> HEADERS = qextserialbase.h \
> win_qextserialport.h \
> posix_qextserialport.h \
> qextserialport.h
> SOURCES += main.cpp \
> qextserialbase.cpp \
> win_qextserialport.cpp \
> posix_qextserialport.cpp \
> qextserialport.cpp
>
> INTERFACES += repeaterdialogwidget.ui
> TARGET = reptest
>
> I use qt3.0.3 enterprise on Win2k, and qextserial ver 0.6, downloaded it
> today from your site.
>
> Sincerely,
> Erlend
>
> --
> List archive and information: http://qt-interest.trolltech.com
>
> --
> List archive and information: http://qt-interest.trolltech.com
>
>
Message 5 in thread
"Erlend Helmersen" <eh@poseidon.no> writes:
> Dear George, thank you for your reply...
>
> I am no expert in windows programming, and this i a class library that
> I hoped to use out of the box...
>
> The actual function call is the one below:
>
> Win_Handle=CreateFile(portName, GENERIC_READ|GENERIC_WRITE,
> FILE_SHARE_READ|FILE_SHARE_WRITE, NULL,
> OPEN_EXISTING, 0, NULL);
>
> where portName is a char array. The definition of CreateFile takes a char
> pointer
> as its first argument, but it seems that for some reason CreateFileW is
> called,
> why?? Is it something with my setup, or what....
CreateFileW is the Unicode version, which gets called if you're supposed
to be using Unicode or something. You can just call CreateFileA
directly to use the ASCII version which takes a const char*.
--
[ signature omitted ]
Message 6 in thread
Hello again.
Thank you for this. The code compiles without any problems,
but I cannot get a simple test program to work. I tried the
below code, and expected to see a series of a's and then
three "test" with new line. What I get (using hyperterminal
set to 4800-N-1 and 8 bit data and no handshake) is just
rubbish. I have tried to change the settings, but cannot
make it work. We have another program (that use only the
windows functions directly) and it works without any problems.
What the qextserialport does seems quite simple, so I cannot see
where the problem is. Any ideas??
QextSerialPort sp("COM1");
char out[]="test\r\n";
sp.setBaudRate(BAUD4800);
sp.setDataBits(DATA_8);
sp.setFlowControl(FLOW_OFF);
sp.setStopBits(STOP_1);
sp.setParity(PAR_NONE);
if (sp.open())
{
sp.putch('a');
sp.putch('a');
sp.putch('a');
sp.putch('a');
sp.putch('a');
sp.putch('a');
sp.flush();
sp.writeBlock(out,strlen(out));
sp.writeBlock(out,strlen(out));
sp.writeBlock(out,strlen(out));
sp.flush();
sp.close();
}
else
{
// handle error
}
> -----Original Message-----
> From: Huber, George CECOM RDEC STCD SRI
> [mailto:George.Huber@mail1.monmouth.army.mil]
> Sent: Thursday, March 21, 2002 15:50
> To: 'eh@poseidon.no'; wroth@speakeasy.org
> Cc: QT
> Subject: RE: qextserialport - problem
>
>
> Hi,
>
> CreateFileW is the unicode version of CreateFile.
> The solution is to make sure that you application is
> unicode compliant, and to define character arrays
> at TCHAR (as I recall). TCHAR is a define that
> translates into char or wchar depending on if
> unicode is enabled.
>
> George Huber
> Computer Scientist
> SRI, International
> phone: 732-427-8064
> fax : 732-427-2065
> cell : 732-740-4018
> george.huber@mail1.monmouth.army.mil
>
>
> -----Original Message-----
> From: Erlend Helmersen [mailto:eh@poseidon.no]
> Sent: Thursday, March 21, 2002 7:15 AM
> To: wroth@speakeasy.org
> Cc: QT
> Subject: qextserialport - problem
>
>
> Dear Wayne Roth.
>
> I try to use the qextserialport classes to add serial communication to my
> application.
> I get this compiler error:
>
> win_qextserialport.cpp(156) : error C2664: 'CreateFileW' : cannot convert
> parameter 1 from 'char [81]' to 'const unsigned short *'
> Types pointed to are unrelated; conversion requires
> reinterpret_cast, C-style cast or function-style cast
> NMAKE : fatal error U1077: 'cl' : return code '0x2'
>
> What is the problem??
>
> This is my .pro file:
> TEMPLATE = app
> CONFIG += qt warn_on debug
> DEFINES += _TTY_WIN_
> HEADERS = qextserialbase.h \
> win_qextserialport.h \
> posix_qextserialport.h \
> qextserialport.h
> SOURCES += main.cpp \
> qextserialbase.cpp \
> win_qextserialport.cpp \
> posix_qextserialport.cpp \
> qextserialport.cpp
>
> INTERFACES += repeaterdialogwidget.ui
> TARGET = reptest
>
> I use qt3.0.3 enterprise on Win2k, and qextserial ver 0.6, downloaded it
> today from your site.
>
> Sincerely,
> Erlend
>
> --
> List archive and information: http://qt-interest.trolltech.com
>
>
Message 7 in thread
You say sou see something (rubbish) on the remote terminal?
Lots of rubbish, or just one character?
If you run hyperterminal instead of your test app, using the same cable,
does that work OK?
Try sending something like 'U' in an infinite loop.
If you have acces to a scope you might be able to figure out the bit rate.
Or try sending "AT\r\n" to a modem a few times. See if "OK\r\n" comes back
----- Original Message -----
From: "Erlend Helmersen" <eh@poseidon.no>
To: "Huber, George CECOM RDEC STCD SRI"
<George.Huber@mail1.monmouth.army.mil>; <wroth@speakeasy.org>
Cc: "QT" <qt-interest@trolltech.com>
Sent: Friday, March 22, 2002 1:50 PM
Subject: RE: qextserialport - problem
> Hello again.
>
> Thank you for this. The code compiles without any problems,
> but I cannot get a simple test program to work. I tried the
> below code, and expected to see a series of a's and then
> three "test" with new line. What I get (using hyperterminal
> set to 4800-N-1 and 8 bit data and no handshake) is just
> rubbish. I have tried to change the settings, but cannot
> make it work. We have another program (that use only the
> windows functions directly) and it works without any problems.
>
> What the qextserialport does seems quite simple, so I cannot see
> where the problem is. Any ideas??
>
> QextSerialPort sp("COM1");
> char out[]="test\r\n";
>
> sp.setBaudRate(BAUD4800);
> sp.setDataBits(DATA_8);
> sp.setFlowControl(FLOW_OFF);
> sp.setStopBits(STOP_1);
> sp.setParity(PAR_NONE);
>
> if (sp.open())
>
> sp.putch('a');
> sp.putch('a');
> sp.putch('a');
> sp.putch('a');
> sp.putch('a');
> sp.putch('a');
> sp.flush();
>
> sp.writeBlock(out,strlen(out));
> sp.writeBlock(out,strlen(out));
> sp.writeBlock(out,strlen(out));
> sp.flush();
>
> sp.close();
> }
> else
> {
> // handle error
> }
>
> > -----Original Message-----
> > From: Huber, George CECOM RDEC STCD SRI
> > [mailto:George.Huber@mail1.monmouth.army.mil]
> > Sent: Thursday, March 21, 2002 15:50
> > To: 'eh@poseidon.no'; wroth@speakeasy.org
> > Cc: QT
> > Subject: RE: qextserialport - problem
> >
> >
> > Hi,
> >
> > CreateFileW is the unicode version of CreateFile.
> > The solution is to make sure that you application is
> > unicode compliant, and to define character arrays
> > at TCHAR (as I recall). TCHAR is a define that
> > translates into char or wchar depending on if
> > unicode is enabled.
> >
> > George Huber
> > Computer Scientist
> > SRI, International
> > phone: 732-427-8064
> > fax : 732-427-2065
> > cell : 732-740-4018
> > george.huber@mail1.monmouth.army.mil
> >
> >
> > -----Original Message-----
> > From: Erlend Helmersen [mailto:eh@poseidon.no]
> > Sent: Thursday, March 21, 2002 7:15 AM
> > To: wroth@speakeasy.org
> > Cc: QT
> > Subject: qextserialport - problem
> >
> >
> > Dear Wayne Roth.
> >
> > I try to use the qextserialport classes to add serial communication to
my
> > application.
> > I get this compiler error:
> >
> > win_qextserialport.cpp(156) : error C2664: 'CreateFileW' : cannot
convert
> > parameter 1 from 'char [81]' to 'const unsigned short *'
> > Types pointed to are unrelated; conversion requires
> > reinterpret_cast, C-style cast or function-style cast
> > NMAKE : fatal error U1077: 'cl' : return code '0x2'
> >
> > What is the problem??
> >
> > This is my .pro file:
> > TEMPLATE = app
> > CONFIG += qt warn_on debug
> > DEFINES += _TTY_WIN_
> > HEADERS = qextserialbase.h \
> > win_qextserialport.h \
> > posix_qextserialport.h \
> > qextserialport.h
> > SOURCES += main.cpp \
> > qextserialbase.cpp \
> > win_qextserialport.cpp \
> > posix_qextserialport.cpp \
> > qextserialport.cpp
> >
> > INTERFACES += repeaterdialogwidget.ui
> > TARGET = reptest
> >
> > I use qt3.0.3 enterprise on Win2k, and qextserial ver 0.6, downloaded it
> > today from your site.
> >
> > Sincerely,
> > Erlend
> >
> > --
> > List archive and information: http://qt-interest.trolltech.com
> >
> >
>
> --
> List archive and information: http://qt-interest.trolltech.com