hello everyone, I am a new member. For my project I have to send binary data (like 10001110) to the db9 rs232 port. I use visual c++ 6.0. I found some codes but they could not work properly. Can anyone give me a c++ code for this problem? Thank you...
5 10977
hello everyone, I am a new member. For my project I have to send binary data (like 10001110) to the db9 rs232 port. I use visual c++ 6.0. I found some codes but they could not work properly. Can anyone give me a c++ code for this problem? Thank you...
what is the problem? do you have functions to read/write the serial ports? are they not working correctly? don't you get anything tranbsmitted when you send data?
have a look at
http://www.thescripts.com/forum/thread608179.html
- #define STRICT
-
#include <tchar.h>
-
#include <windows.h>
-
#include "Serial.h"
-
-
int WINAPI _tWinMain
-
(
-
HINSTANCE /*hInst*/,
-
HINSTANCE /*hInstPrev*/,
-
LPTSTR /*lptszCmdLine*/,
-
int /*nCmdShow*/
-
)
-
{
-
CSerial serial;
-
-
// Attempt to open the serial port (COM1)
-
serial.Open(_T("COM1"));
-
-
// Setup the serial port (9600,N81) using hardware handshaking
-
serial.Setup(CSerial::EBaud9600,CSerial::EData8,CSerial::EParNone,CSerial::EStop1);
-
serial.SetupHandshaking(CSerial::EHandshakeHardware);
-
-
// The serial port is now ready and we can send/receive data. If
-
// the following call blocks, then the other side doesn't support
-
// hardware handshaking.
-
serial.Write("Hello world");
-
-
// Close the port again
-
serial.Close();
-
return 0;
-
}
I have used this code and it says "Just call the Write method and supply a string. The Write routine will detect how long the string is and send these bytes across the cable."
But program give some errors while building the exe file.
the HelloWorld.cpp program from
http://www.codeproject.com/system/serial.asp
compiles and links OK for me - when you linked did you include the serial.cpp file?
to run it I switched off hardware handshaking then it transmitted "hello world" to a another PC via the serial port at 9600 baud
- #define STRICT
-
#include <tchar.h>
-
#include <windows.h>
-
#include "Serial.h"
-
-
int WINAPI _tWinMain
-
(
-
HINSTANCE /*hInst*/,
-
HINSTANCE /*hInstPrev*/,
-
LPTSTR /*lptszCmdLine*/,
-
int /*nCmdShow*/
-
)
-
{
-
CSerial serial;
-
-
// Attempt to open the serial port (COM1)
-
serial.Open(_T("COM1"));
-
-
// Setup the serial port (9600,N81) using hardware handshaking
-
serial.Setup(CSerial::EBaud9600,CSerial::EData8,CSerial::EParNone,CSerial::EStop1);
-
serial.SetupHandshaking(CSerial::EHandshakeHardware);
-
-
// The serial port is now ready and we can send/receive data. If
-
// the following call blocks, then the other side doesn't support
-
// hardware handshaking.
-
serial.Write("Hello world");
-
-
// Close the port again
-
serial.Close();
-
return 0;
-
}
I have used this code and it says "Just call the Write method and supply a string. The Write routine will detect how long the string is and send these bytes across the cable."
But program give some errors while building the exe file.
hello can you just send the serial.h code used in ur programming
hello i am writting the code in vc++ to send data to serial port,i am the begginer of this,can anybody help me to write code
Sign in to post your reply or Sign up for a free account.
Similar topics
by: coder_1024 |
last post by:
I'm trying to send a packet of binary data to a UDP server. If I send
a text string, it works fine. If I attempt to send binary data, it
sends a UDP packet with 0 bytes of data (just the...
|
by: gof |
last post by:
I'm pretty new to C++, and this seemingly simple thing is driving me
crazy. I'm trying to write a CGI script to serve images on the fly.
CGI requires the content to be sent through standard...
|
by: Pravin Prabhu |
last post by:
Hi,
How can i send binary data over a network using winsock. I dont want to
use a char array as the binary data has a lot of 'NUL' characters in it which
causes problems when i receive data using...
|
by: Schwarty |
last post by:
I hope I posted this to the correct group. If not, please let me know and I
will get it posted in the correct section.
I have a web application developed in ASP.NET using C# for the code behind....
|
by: thorley |
last post by:
Greetings, since there was no reponse to my previous post about an
existing FastCGI server in python, I've taken to writing my own. (which
of course I'll share--*if* there's something to share ;)
...
|
by: John Graham |
last post by:
I'm using a transferText command on a Query that is joining several
tables and pulling data off of a form. Â However all the fields from
the
form are coming across as what I believe is Binary...
|
by: Rich |
last post by:
Hello,
I am working on a python library for sending and receiving data from a Subaru's ECU (the fuel injection computer) via the OBD-II port and an OBD to USB cable, with the Subaru Select Monitor...
|
by: Gabriel Genellina |
last post by:
En Fri, 02 May 2008 16:50:46 -0300, Rich <richietommy@yahoo.comescribió:
No, chr works as it should. The same thing can be written as
ser.write("\x80\x10\xF0\x01\xBF\x40")
Are you sure you're...
|
by: jen786 |
last post by:
Hello every one ,
This is my first message on fourm ....looking forward to reply
This is regarding serial port in visual basic 2008.
when i run the following VB program. After 2 minutes it...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
| |