473,767 Members | 2,302 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Transmit binary byte on serial port ?

we have a project to transmit and receive data on serial port (i modify it
from VCTERM on MSDN). To transmit text byte I use :
void CMainFrame::TxS tring(CString str)
{
CString s;
VARIANT vCommOut;
vCommOut.vt = VT_BSTR;
vCommOut.bstrVa l = str.AllocSysStr ing();
mCommCtrl.SetOu tBufferCount(0) ;
mCommCtrl.SetOu tput(vCommOut);
SysFreeString(v CommOut.bstrVal );

while(mCommCtrl .GetOutBufferCo unt()>0)
DoEvents();
}

it run OK, unless the byte that has value 0x00.

to resolve that, I use :
void CMainFrame::TxB yte(unsigned char ch)
{
VARIANT vCommOut;
vCommOut.vt = VT_UI1;
vCommOut.bVal = ch;
mCommCtrl.SetOu tBufferCount(0) ;
mCommCtrl.SetOu tput(vCommOut);

while(mCommCtrl .GetOutBufferCo unt()>0)
DoEvents();
}

when I run it, system gives error message "invalid value" at line:
mCommCtrl.SetOu tput(vCommOut);

Please give me a solution to transmit binary byte.
Thank regard !
Nov 17 '05 #1
0 1486

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
3944
by: Liu Ju | last post by:
Dear members: I need to write a program in Visual C++ platform that trasmit data through the COM port. The task would be as follows: Whenever the peripheral device sents 1 byte to the computer through the RX pin of the COM Port, the program will send 4 bytes to the TX pin to peripheral device. do you know any source or the class in Visual C++ on the Internet that can reliably transmit data through COM port ?
21
3114
by: nephish | last post by:
i have an interesting project at work going on. here is the challenge. i am using the serial module to read data from a serial input. it comes in as a hex. i need to make it a binary and compare it bit by bit to another byte. They have some weird way they set this up that i have to compare these things with AND. in other words, if bit 1 is 1 AND bit 1 is 1 then the real value is 1... long story short. is there a good way to compare...
4
11163
by: Tom Van Ginneken | last post by:
Hi, I need to write binary data to a serial port. I am using this function: #include <unistd.h> ssize_t write(int fd, const void *buf, size_t count); I am able to write a alpha-numeric character to the port using this: write (filedescriptor,"a",1);
1
1718
by: arrowlike | last post by:
In a VC6 program, a mscomm32.ocx is added to the project and read the binary incoming RS232 data stream (from a GPS receiver). I use another commercial serial port debug program to send out a binary file through com port, read and record the com port data into a disk file. After file comparison, no error occurs. When the GPS receiver is connected, my program drops or adds one or two bytes in each data block which is about 200 bytes. The...
0
323
by: QuangPK | last post by:
we have a project to transmit and receive data on serial port (i modify it from VCTERM on MSDN). To transmit text byte I use : void CMainFrame::TxString(CString str) { CString s; VARIANT vCommOut; vCommOut.vt = VT_BSTR; vCommOut.bstrVal = str.AllocSysString(); mCommCtrl.SetOutBufferCount(0); mCommCtrl.SetOutput(vCommOut);
3
2741
by: Rasha | last post by:
Hi, What is the right way for transmitting data on the serial port of a PC using VB.NET (under XP) ? I used to use the ActiveX MSComm under VB6, which becomes obsolete and needs a certification, only available if Visual Studio 6 is installed. Thanks for any Help !!!
1
1580
by: John Wright | last post by:
I have a device hooked up to my COM port that I read data from the serial port into my program. If the device is in its double mode the information that comes back is an 8 bit binary field for each record on the machine. Set up as follows Bit 7 -- Data type (Set to a 1) Bit 6 -- Not used (set to 0) Bits 5 - 0 -- Set to a 1 if the corresponding field is checked on the machine.
1
15099
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 protocol. There are a few open source programs that do this already (http://romraider.com/ , http://jdash.sourceforge.net/ , http://tari.co.za/downloads/software/source/ ), but they are written in Java or C++. I have never done anything with serial...
0
1365
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 talking to the right device, /dev/ttyUSB0? Are the comm parameters correct? (BTW, if you get more than a single character per loop, the print statement will fail - try with ser.read(1))
0
9571
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10168
Oralloy
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10009
jinu1996
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9838
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7381
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6651
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5279
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3929
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3532
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.