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


ADVERTISEMENT

C++ :: Capture Incoming Serial Data And Store It Into Array For Controlling Functions

Mar 22, 2014

How to capture incoming serial data and store it into an array for controlling functions. But I am now working with a radio module that receives incoming data and stores it into a uint_8t.

From there in the basic sketch that the radio library came with it is printed in the serial terminal like this:

uint8_t buf[RF22_MAX_MESSAGE_LEN];
uint8_t len = sizeof(buf);
if (rf22.waitAvailableTimeout(500)) {
// Should be a message for us now
if (rf22.recv(buf, &len)) {
Serial.print("got reply: ");
Serial.println((char*)buf);

I have read a lot of tutorials on pointers, and I am just having a very hard time grasping how to extract data out of one. I realize this is char and not integers. The goal is to transmit five integers in a digital state of either 1 or 0, and then store them in the receiving side and control 5 outputs based on the status of those 5 bits. This is proving to be quite confusing for me though as I cannot seem to grasp how to control the pointer logic.

View 1 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

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

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++ :: 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

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

C++ :: Reading And Writing Serial Data From USB

Jan 19, 2015

I am trying to make a project using arduino to control several power surces by time, i don't want to have an lcd, that would be easyer but i don't have enought space on my project, i want to set the time and the timing for the relays via Serial

Of curse i could set it using the serial monitor on the arduino ide, but i want to make a simple program to make the pc comunicate with the arduino and make it simpler to set the time and similar stuff. How to use one of my usb ports to print and read serial data?

View 1 Replies View Related

C# :: How To Send And Receive Data From Serial Port

Aug 13, 2014

private void button1_Click(object sender, EventArgs e) {
serialPort1.PortName = "COM1";
serialPort1.BaudRate = 9600;
serialPort1.DataBits = 8;
serialPort1.Parity = Parity.None;
serialPort1.StopBits = StopBits.One;

[Code]...

In my project i have a serialport control and a button, there is no error but i want to know how actually this works, i want to send and recieve the data from the serial port don't know how to do it..

View 9 Replies View Related

C# :: Receive Data From Serial Com Port In One Line And Convert To Int

Mar 8, 2014

i have problem i make code that take data from serial com port for weighting machine it is ok working but it recieve data in more lines.I try to make it receive data in one line In code below i need to take weight fro weight bridge machine automatically by timer in visual studio 2005.it works but receive weight values in more lines. I need to receive weight in one line and automatically updated then convert t to integer

void Application_Idle(object sender, EventArgs e)
{
label3.Text = serialPort1.IsOpen ? "[Open]" : "[Closed]";
}

[Code].....

View 3 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

C++ :: Publish Data Over The Internet In Peer To Peer Style Communication?

Sep 24, 2012

I need to be able to publish data between multiple machines at remote locations. I have been able to send data between two machines on a network in the same room. However, how to begin with resolving IPs for machines on other networks that are miles away etc. I would assume the application would need to LISTEN & PUBLISH in order to achieve this?

I have also googled this, and can only seem to find C# examples, and they seem to be for data between remote computers on the same network... What I need is to be able to find some guidance on sending data between me and someone who I previously had no knowledge of. I know this must be possible due to the fact that p-2-p chat clients exist, and that p-2-p file sharing exists.

View 1 Replies View Related

C :: Store Data In Binary File Then Use It To Find Inverse Of Matrix Form Of Data

Dec 6, 2013

I need to find inverse of a matrix data in binary file should be used to form matrix.its not finding inverse correctly rest is working good.

Code:
#include <stdio.h>
void createbin();
void display();
void inverse();
int main()
{
createbin();
display();
inverse();

[Code] ....

View 4 Replies View Related

C++ :: Add Data To Text Files Which Are Required To Store 3D Scan Data

Jul 10, 2013

I have written the following code to add data to text files which are required to store 3D scan data (I have to calculate the y-coordinate). My code seems to work except that it stops working when I want to create more than ten text files i.e. the directory I am trying to store them in will not hold any more than ten text files. Code is shown below.

#include <string>
#include <locale>
#include <iomanip>
#include <iostream>
#include <fstream>
#include <sstream>
using namespace std;

[Code] ....

View 1 Replies View Related

C++ :: Stream Iterators And Buffers?

Feb 6, 2013

Do stream iterators, such as std::istreambuf_iterator<char>, read a chunk of bytes internally, or do they read the stream one byte at a time?

Because I am thinking to write a BufferedFile class which uses an std::vector<char>.

View 3 Replies View Related

C/C++ :: How To Use UMDF Driver Request Buffers

Feb 18, 2015

I am trying to create "dummy" drivers for testing purposes of another program of mine.

I want to be able to Call DeviceIoControl and pass a string in as the buffer and then receive that string in the driver, change it and return it. But right now I am not able to receive the string, when i get the buffer and print it out it is garbage. Where am I going wrong?

TEST

int _tmain(int argc, _TCHAR* argv[]) {
BOOL freeResult, runTimeLinkSuccess = FALSE;
HANDLE RTC_IOControlHandle = NULL;
HINSTANCE FRS_IOControlHandle = NULL;
RTC_IOControlHandle = CreateFile(L"\.ROOT#SAMPLE#0000#{db3d5a0e-63aa-4b97-9d05-b50d5093a20f}",
FILE_SHARE_READ | FILE_SHARE_WRITE,
0,//FILE_SHARE_READ | FILE_SHARE_WRITE,

[code]....

View 4 Replies View Related

C# :: Concurrent Sharp Panel Connection With Semaphores And Buffers

Apr 26, 2014

I have a problem with my C#. Trying to create the airstrip with planes heading out of the hangars and on to the road to the airstrip. Each Hangar pannel is connected with closes road to them. What i am stuck with right now is connecting the roads together so each one of them will see if the next road is free and if it is it will send the plane (colorder square for now) to it and then proceed to the next one when finaly they will line up for the final panel(airstrip) and take off.So far they are just going down the each road they are assigned with semaphore and thread.

using System;
using System.Windows.Forms;
using System.Threading;
using System.ComponentModel;
using System.Collections;
using System.Data;
using System.Drawing;

[Code] ....

Connecting the "p2" with "p5" so the graphics from "p1" the square will travel through P2 and P5 this would be great and will allow me to procede with my studies.

Also i do realise that this might not be the best ways of using concurrent Csharp and not the up to date one but this is what i have been assigned with and do not have any other options unfortunately.

How i understand this is that i need to have 3 buffers and 3 semaphores for each panel. But i do not know how to add those to each one of them and then connect it with the next one as if i try and add them it either puts a cross in the design view over that panel or says that there is limited options for this statement.

This is the way that i want to do it unfortunately it must be so. The most flexible this can be is by adding an array for semaphores and buffer ( do not know how to do that either).

View 7 Replies View Related

C# :: One Thread Trying To Pass Data To Another Thread Using Serial Port

Jul 30, 2014

I have a class which I wrote and one of its object is "SerialPort" .NET class. In my MainWindow I created instance of my class called "SerialPortComm", then I send through some functions of mine, commands to the Serial Port, and I receive answers through "DataReceived" event.

But when I trying to use Dispatcher.BeginInvoke to write my data I have received (successfully), nothing shows on the RichTextBox which I'm trying to write to.

What can caused that, and How I can make it works?

SerialPortComm.cs

public partial class SerialPortComm : UserControl {
public SerialPort mySerialPort = new SerialPort();
public void Open_Port(string comNumber, int baudRate) {
mySerialPort.PortName = comNumber;
mySerialPort.BaudRate = baudRate;

[Code] ....

View 7 Replies View Related

C++ :: Best Way To Store Data?

Jul 8, 2013

struct Book{
string bookTitle;
string ISBN;
string author;
string publisher;
string dateAdded;
int qty;
double wholesale;
double retail;
};

What's the best way to store multiple of the above structure?Ideally, it would be with a binary output, but that isn't possible with the strings, unless I'm missing something. So that leaves me with two options.

-Create a second structure that has an outrageous char[] length, and then copy the data from the original structure to write/read to/from the file. The flaws I see in this is excess runtime with copying, and a larger amount of memory is temporarily needed. The positive I see is I can use binary output, which is easier.

-The second option is to just use an ASCII file, and put each element on it's own line, and then just use getline to read each line. The flaw I see in this is that I have to read the file into the structure, instead of just reading the structure and the file can be tampered with (Not a huge concern). The positive is the lack of negative from the above.

View 4 Replies View Related

C :: How Data Actually Store In File

May 19, 2014

How data actually store in the File. Like do data store just in one line or at different places for example in array data store in adjacent memory block while in struct data store at different memory block.?

View 2 Replies View Related

C++ :: Using Arrays To Store Data?

Mar 25, 2013

start writing a program to store some information and then have it recalled. I would like to be able to store a list of the video games I own because i thought it would be fun :)

View 1 Replies View Related

C++ :: How To Store Data Into Array

Apr 18, 2013

How can I store this data into an array?And I only can read the first integer.. 10.... How can I read the whole file...Heres the data:

10 alice 4/23/1972 123-45-6789 support assistant
3 bob 6/7/1980 111-12-1134 logistics manager
1 carol 10/2/1963 987-123-1143 admin ceo
2 dave 10/3/1974 902-22-8914 admin cfo
17 erin 6/13/1991 126-83-1942 technology supervisor
15 frank 2/22/1987 303-12-1122 logistics assistant

Heres what I have so far?

#include <iostream> //Accesses libaries for console input and output
#include <fstream> //Needed to access the fstream object to read files
#include <string> //Needed to access the string class
#include <cstdlib>

[code]....

View 1 Replies View Related

C :: How To Store Data Structure Into 2D Array

Mar 22, 2013

I have this data store into a data structure.

i j x y w h w*h
0 0 0 0 9 11 99
1 0 0 11 9 10 90
2 0 0 21 9 11 99
0 1 9 0 8 12 96
1 1 9 12 8 7 56
2 1 9 19 8 6 48

[Code]...

Code:

struct data {
//Here
/*! horizontal position */
int x;
/*! vertical position */
int y;
/*! width */
int w;
/

[Code]...

data and then i have an array /*! it contain group_id of each data line*/ int group_id[16]={0,0,0,0,3,3,1,1,1,3,3,2,2,2,2,1}; I never worked with 2D array before. My problem is that i want to create a 2D array of that data for example if i write data[j][i].. It will give me the reference/value of all data lines that belongs to j column, and same with group_id[j][i]. I don't know how i can store these structure vaules in this like 2D array.

View 2 Replies View Related

C++ :: How To Store Data From A Class Into A Container

Feb 10, 2013

I'm having trouble understanding on how to actually store into a container from another class. Any simple example.

View 9 Replies View Related

C++ :: How To Store And Retrieve Data In Class

Aug 20, 2014

I have a class I use to store column data read from delimited text files.

Code:
class column_data {
// class functions here
public:
// initialize class members
column_data()
: header(""),

[Code] ....

Each column is read into the vector of string. Next the string data is copy converted to the vector of double or the vector of int depending on the data type. There can also be additional transformations of the data (normalization, scaling, etc) and the transformed data is copied to the transformed_double_data vector. I do end up with multiple copies of the data, but I can clear some of the vectors if I don't need all the versions of the data anymore. Each column object goes into a container like a vector of objects or map of objects depending on how I need to access the column data.

There are functions that calculate statistics on the data in the columns and the results are assigned to the object variables like validate_r2. There are separate statistics for each column, so it seems logical to store the results in the column object. This works well for statistics like validate_r2 (pearson's correlation coefficient).

The current issue is that I have other statistics like "pw50" that I need to calculate and store. The statistic is the percent within +/- 50 units and the request for pw50 is passed in from the command line. The issue is that there could be several of these and they can have more or less any value like, pw50, pw75, pw100, etc. Storing data like this doesn't fit into my scheme very well because I can't pre-declare a variable to hold the result for every possible option. I don't know in advance how many, if any, of these there will be. I was thinking of adding two vectors, one of string and one of double,

Code:
class column_data {
public:
// initialize class members
column_data()
: header(""),
type(""),
use(""),
validate_r2(0.0),

[Code] ....

For each of this type of statistic requested, I would push_back a label into the string vector and then put the result into the parallel position in the double vector. This seems like I would work, but there are probably some things that could be done with pointers that might be better. Another option would be a vector of objects where each object had a string value for the label and a double for the result. That would be more bullet proof as far as keeping the label and value together, but I have not ever nested objects in a class like that so I thought I would post. I don't know the syntax for declaring an object of class_b inside the definition of class_a. The need is to provide dynamic storage for an unspecified number of these statistics and a reliable way to retrieve the values using the label.

View 1 Replies View Related

C++ :: How To Store Data By Descending Order Auto

Oct 27, 2014

I wanna store my data by descending order auto without doing a classification after , i have come up with a code but it crashes.

Code:
void list::create(int num) {
struct node * n,*temp;
n=new node;
n->data=num;
if(head==NULL)

[Code]....

I don't wanna use the list library with the push.buck, i need to do it by coding it without fix functions ....

View 3 Replies View Related







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