Visual C++ :: COM Port Communication

Nov 30, 2012

How to communicate my COM PORT to my visual c++ ... Means i want to read data from my port and want to show in visual c++ so what to do ...

View 1 Replies


ADVERTISEMENT

C++ :: SerialPort Communication - Reading Data From Port And Storing In One Document

Jun 27, 2014

I am doing SerialPort communication program where i am opening the port and reading data from port and storing in one document.

I debug my program and check that my read function is reading the data properly but when checking the document i find only unicode.

Suppose I am sending 1,2,3,4 to port i able to read same but my document showes þÿÿ þÿÿ þÿÿ þÿÿ

//My Read Function which read data from serial port
tInt serialport::Read(tVoid* pvBuffer, tInt nBufferSize) {
tInt nBytesRead = 0;

[Code] ....

Why I am getting unicode instead of 1,2,3,4 in my document ....

View 3 Replies View Related

Visual C++ :: PIC To PC Using MFC Visual Studio Through Serial Communication

May 28, 2014

The project is about reading data from PIC and display the data on the dialogue created by the MFC GUI of Visual studio 2010. There are 4 data need to be displayed (2 weight and 2 angle). the data will be display on the edit control box on the dialogue.

I have try to solve the COMPort and Readdata issues many times, but I'm fail. I have read many sources and implement the source codes... They are never work....

The detail about the issues that I need to solve is clearly mentioned on the main dialogue.cpp. Take a look to an uploaded zip file that I have attached.

View 6 Replies View Related

Visual C++ :: Communication Between Two Programs Via Registry?

Jan 24, 2014

I'm trying to set up some basic communication between two programs via the registry.

For this I would like to use the functions

Code:
int value=10;
CString strSection="Data";
CWinApp* pApp = AfxGetApp();
pApp->WriteProfileInt(strSection,ValueName,value);
and

Code:
CString strSection="Data";
CWinApp* pApp = AfxGetApp();
int value=pApp->GetProfileInt(strSection,ValueName,0);
which read/write to the application's registry.

Is there some way of making two different programs use the same application registry?

View 14 Replies View Related

Visual C++ :: Manage Serial Communication With A Pedal

Jan 17, 2013

I wrote a class pedal that allows to search for the serial port on which the pedal is connected. Therefore I send a request to the pedal and set up a timer event of 20 ms. If no reply, I search for the next serial port.

When found I send configuration to the pedal and set another timer event of 200 ms that requests for pedal state. It runs fine.

Now if the pedal is disconnected then connected again I would like it to run again.

Therefore I set another timer event every 2s that launches all what I described above.

The trouble comes because the 20 ms timer event doesn't run and I do not understand why.

View 3 Replies View Related

Visual C++ :: Serial Communication In Windows - ClearCommError Finds No Data In Read Buffer

Dec 13, 2013

I want to send data from a laptop (windows 7, processor 2.60GHz) to a desktop (windows xp, processor 3.10GHz) using serial communication (using a USB to RS232 convertor). The WriteFile function is able to send the data from the laptop (NumberOfBytesWritten is correct). But on the desktop side, ClearCommError detects no data in the read buffer.

This is the relevant code in my desktop:

while(1) {
ClearCommError(hPort,&dwErrors,&commStatus);
if (commStatus.cbInQue != 0) ReadFile(hPort,&data,1,&dwBytesRead,NULL);
Sleep(10);
}

The if condition is never satisfied. The baudrate and other parameters in the DCB struct are the same on both sides.

The same code works when I write and read in the same system by shorting the RX and TX pins in the RS232 connector.

View 2 Replies View Related

Visual C++ :: Using The Same Port For 2 UDP Multicast Groups?

Jun 20, 2014

I habe a program, that can send and receive UDP Multicast telegrams. When I open the socket then I bind my multicast group address and the local port to a specified networkcard (our PC has 2 network cards). Now I have a special constellation:

Our PC has 2 network cards. Multicast group 1 shall use card 1 and group shall use card 2. As long as both groups use different local ports it works fine. But when both group want to use the same port number then I can receive and send telegrams only through the first group that was created. For the second one I don't even get a FD_READ event at all.

Code:
SrvAddr.sin_family = AF_INET;
SrvAddr.sin_port = htons( (WORD) nLocalPort );
SrvAddr.sin_addr.s_addr = inet_addr(strOwnIpAddress); // bind multicast group socket to a specified networkcard
// If bind socket to port failed
if( bind( hSocket,

[Code] .....

View 2 Replies View Related

Visual C++ :: How To Read And Write On Serial Port With MFC

Feb 17, 2013

I want to read and write value on serail port to Microcontroller with MFC. The MFC have no serial port tool like in VB Professionnal edition. I try to find MFC connect serial port example but I not found. If you have good example for read and write on serial port with MFC

View 2 Replies View Related

Visual C++ :: Data Stuck When Debugging With Serial Port

May 10, 2014

I am making a MFC application with VC++2012 with receiving data from Serial Port and the data is stored in a Listbox, then after processing (convert into numbers) and get these data to draw a sine wave on the chart. (I intend to make a virtual oscilloscope).

Everything works ok at the beginning, but after receiving about 300 items or above (in the Listbox) the value seem stucking (or lagging) and work very slowly.

I receive data by the SerialPort_DataReceived() method, and process of converting and drawing chart also in this method, I think this makes the system overload!!

View 1 Replies View Related

Visual C++ :: Getting Port Number Of A Packet In Pcap File

Jan 19, 2014

I am programming in c++ with 'winpcap' . I read a .pcap file and after I want to get the source and destination of packets in that file. Here is a piece of my code:

Code:
////I define the sructures here
#pragma pack(1)
struct sniff_ethernet {
u_char ether_dhost[ETHER_ADDR_LEN]; /* Destination host address */
u_char ether_shost[ETHER_ADDR_LEN]; /* Source host address */
u_short ether_type; /* IP? ARP? RARP? etc */

[Code] ....

but the result is incorrect? where is the problem?

View 5 Replies View Related

Visual C++ :: Sending Packet Of Type Byte To Serial Port

Feb 26, 2013

I need to send a packet of type byte:

0x00, 0x01, 0x02, 0x11, 0x00, 0x00

to a device via the serial port and then I receive and store data coming from device like this:

0x01, 0x01, 0x01 , 0x00, 0x00, 0x00, 0x01, 0x00, 0x04, 0x01, 0x00.

Writing lines of code through which:

1) I create the array
2) the sending the array to serial port
3) I'll see what I'm sending
4) I get the data

I'm using Visual Studio 2010 and C + + or VC++ language.

View 14 Replies View Related

C :: USB To Serial Communication Using Language

Dec 18, 2013

I have to communicate between two laptops using USB-to-Serial adapter. I have written 2 programs one for sending and another for receiving. Programs were written in both C and C# programming languages.

Using C language: I am able to successfully communicate using C-Programs mentioned below. But the problem is speed. It takes around 1 hour(60min) for just to pass 150MB. improving the performance of this programs...I also mention some comments along with programs for self understanding.Sender File on laptop with serial port :

Code:

#include <stdio.h>
#include <bios.h>
#include <conio.h>
}

[code]....

The above 4 programs behaves as, sender send a character and receives an ack for every character. I have followed this approach, bcoz other approaches were not working fine (in the sense the complete data is not sent, the amount of data sent is not judgeable, bcoz it will different every tym). when i used this approach it worked fine.

View 6 Replies View Related

C++ :: Communication Between Functions Of Class

May 19, 2013

I have a class as follows:

class testa {
public:
testa_b();
~testa_b();
testa_c();
}

Then I have defined some variables in testa_b:

testa::testa_b()
{
double aa = 1.0;
}

What is the easiest way to make testa_c() can use the aa defined in testa_b() (without declaring them in the class)?

View 3 Replies View Related

C++ :: Two Way Event-driven Communication Between Objects

Oct 26, 2013

I need to implement a two-way asynchronous communication between two objects, not using any IPC.

What I have now is a producer-consumer model where producer sends a number "88" to consumer at random intervals. Now, I need consumer to send a number "99" back to producer at a random intervals, this probably should be done in a separate thread.

I am using GNU on Linux, here is the compile line.

Code:

g++ -g -std=c++11 main.cpp -o main

Code:

#include<iostream>
#include<chrono>
#include<thread>
class IObject {
public:
virtual void fromApp(int i) = 0;
virtual int toApp(int& i) = 0;// ???

[code].....

View 8 Replies View Related

C++ :: Implement Bidirectional Communication Between Two Processes?

Mar 29, 2012

I have two command line apps, one of them is multithreaded. I need to implement a bidirectional communication between them. Currently I can do

Code:
ProgramA 1> ProgramB

for the first programA to direct output into ProgramB, however I also need ProgramB to send messages to ProgramA.

how to implement it in a easiest way.

btw, I am on Ubuntu. I'd rather not to use third party libraries, Boost, etc.

View 7 Replies View Related

C :: Simple Way To Have Instant Communication In TCP/IP Chat Program?

Mar 25, 2014

My program allows a server and a client to chat over a socket. Currently I have to wait for one of them to type a message and press enter, before a message from the other person can be received.

Is there a simple way for messages to be received instantly - but not disturb any message that is being typed in?

View 2 Replies View Related

C/C++ :: Two Way Communication Between Child And Parent Processes (pipes)

Mar 19, 2014

I want parent and child processes to communicate in C linux using pipes. I have created two file descriptors. one for parent to child i.e. readpipe and other writepipe for viceversa. But I am getting null as output for ch and ch1 strings in my code below.

#include <stdio.h>
#include<stdlib.h>
#include
#include<unistd.h>
int main(){
pid_t pid;

[Code] .....

View 1 Replies View Related

C :: How To Capture And Store Serial Communication Data In Buffers

Jun 18, 2013

I sent 1preample and 4bytes in transmitting side , preample contains only 1 and 0 with 4milliseconds delay, each byte contains 8bits with 2milliseconds delay , if a bit contains 1 it will send 1millisecond high and 1millisecond low signal ,and if a bit contains 0 it will send 2millisecond continuous delay, I have a problem at receiving side how to capture and store the preample and 4byte values in a buffer , i am using ARM processor it will update every 5microsecond ..

View 1 Replies View Related

C :: Port Mixer From OSS To ALSA

Jan 27, 2013

I'm new in c programming and my requirement is as follows. I make a code for oss mixer and now when new systems, throwing the OSS, and there is no /dev/mixer I want to port my code to alsa but my skills are minimal.

Code:
static int mixer_fd = -1, mixer_src = -1;
static char *devices[] = SOUND_DEVICE_NAMES;
int mixer_init(char *mixer_device, char *mixer_source) {
int i;

mixer_src = -1;
for (i=0;i<SOUND_MIXER_NRDEVICES;i++)
if (strcmp(mixer_source, devices[i]) == 0)

[Code] ....

Coexistance with OSS would be nice, so both could be used depending on users choice. Perhaps: if this first
part of the mixer name is a valid device file, try OSS, otherwise try ALSA?

View 1 Replies View Related

C# :: How To Multithread Port Scanning App

Jan 24, 2012

I'm creating a small port scanning app which use a port range defined by user.My problem with the code is that I find it not efficient enough meaning that it ping very slow, especially when ports are not responding meaning that I must wait for the timeout before continuing to next port.

I want to make this small app threaded. The problem here is that I'm kind of blank of how to implement threading in my program. This is my code which is a method which does the actual checking, the other part of the code is a simple button with for loop for advancing my port number.

Code:

private void ScanPort(IPAddress address, int port) {
using (TcpClient client = new TcpClient() {
IAsyncResult result = client.BeginConnect(address, port, null, null);

if (result.AsyncWaitHandle.WaitOne((int)nudTimeout.Value, false)) txtDisplay.AppendText("Port: " + port + " is open." + Environment.NewLine);
else txtDisplay.AppendText("Port: " + port + " is closed." + Environment.NewLine);
} }

I have read some basic threading tutorial but I just don't know how to implement this piece of code so I can check ports much faster.

View 3 Replies View Related

C :: Parallel Port Programming - On / Off LED

Sep 9, 2014

I try to ON and OFF the LED's via parallel port. I connect the cathode of LED's with pin number 18 that is ground and anode of each LED is connected through a 1K resistor to pin 2 to 8. I write the following programe

Code:
#include <dos.h>
#include <stdio.h>
#include <conio.h>
#define PORTID 0x378
void main(){
outportb(PORTID,0x00);
getch()
}

But when i connect the LEDS to the parallel port all the LEDS are LIT while i also change the 0x00 to 0xff and so on. But no effect on the LED's.

View 8 Replies View Related

C :: Parallel Port Where To Start

Jan 1, 2014

I started writing in c because I want to control relays with the parallel port, or anything else. Doesn't really matter what I use I just need to know where to start. Trying to send and receive data from the outside world with c programming on a GNU/Linux os? If so any good some what up to date resources online?

View 5 Replies View Related

C++ :: Output Voltage On USB Port

Oct 26, 2013

I am on a project. I have a laptop and It doesn't have a COM port. So what I would like to do is to get a usb to RS232 cable and write a code so to output voltages on usb and measure it on the RS-232 end. Can I vary the output voltage to my needs?

View 2 Replies View Related

C++ :: Port A Pc Game To Android

Jul 10, 2013

How do I port a pc game to android? Do I just include libraries or do I have to rewrite all my code?

View 5 Replies View Related

C/C++ :: How To Write To The Parallel Port

Apr 16, 2007

How To write to the parallel port under windows xp using Visual C++ ->MS Studio studio 2005

View 4 Replies View Related

C++ :: Inserting Hex Value And Sending It At Serial Port

Dec 17, 2013

I am trying to convert decimal value 1 to 32 to hex value and insert it at 4th pos of char array and send it as hex value at the serial port .

My issue is it is converting to decimal to hex value but when it sends, it treat the converted hex value as char and sends it equivalent hex value.

For example

if decimal =1 then its hex = 1.
so , writebuffer[3] =1

But when we send whole writebuffer through send function, it treat this 1 as char and sends its hex value as 31. how to send its hex value.

unsigned int i=0;
char hex[3];
unsigned char hexunsigned[3];
unsigned int dec;
do {
unsigned char writebuffer[8] ={0x01, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};

[Code] ....

The send function is

void serial::send(unsigned char data[], DWORD noOfByte) {
DWORD dwBytesWrite;
WriteFile(serialHandle, data, noOfByte, &dwBytesWrite, NULL);
}

View 2 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved