C++ :: Saving Packets Of Data To A Vector?

Jul 18, 2014

I am receiving packets of data from an ethernet cable. This is the line of code that is streaming in data from the ethernet cable:

size_t num_rx_samps = rx_stream->recv(&buff.front(), buff.size(), md, 3.0, enable_size_map);[code]

Here are the segments of me trying to push the packets onto a vector:

[code]
std::vector<size_t> processing_queue; //HERE IS WHERE I'M TRYING TO PUSH THE PACKETS ONTO A VECTOR
processing_queue.push_back(num_rx_samps);
[code]

I previously had my program saving to a .dat file (the commented out lines), but I need to change it to pushing values onto a vector so I can stream the data packets from the ethernet cable to be processed. However, the packets aren't being pushed onto the stack as I suspected. What do I need to change to push the data packets onto a vector? The following is the code:

[code]

#include <uhd/types/tune_request.hpp>
#include <uhd/utils/thread_priority.hpp>
#include <uhd/utils/safe_main.hpp>
#include <uhd/usrp/multi_usrp.hpp>
#include <uhd/exception.hpp>
#include <boost/program_options.hpp>

[code]....

View 1 Replies


ADVERTISEMENT

C/C++ :: Pushing Ethernet Data Packets To A Vector?

Jul 17, 2014

I am receiving packets of data from an ethernet cable. This is the line of code that is streaming in data from the ethernet cable:

size_t num_rx_samps = rx_stream->recv(&buff.front(), buff.size(), md, 3.0, enable_size_map);

and here is my attempt to push it onto a vector:

std::vector<size_t> processing_queue; //HERE IS WHERE I'M TRYING TO PUSH THE PACKETS ONTO A VECTOR
processing_queue.push_back(num_rx_samps);

I previously had my program saving to a .dat file (the commented out lines), but I'm trying to change it to pushing values onto a vector so I can stream the data packets from the ethernet cable to be processed. However, I'm having issues with pushing the data packets onto the vector?

The following is the code:

#include <uhd/types/tune_request.hpp>
#include <uhd/utils/thread_priority.hpp>
#include <uhd/utils/safe_main.hpp>

[Code].....

View 1 Replies View Related

C :: Saving Matrices With Data Structures?

Dec 4, 2014

I'm taking a programming class and currently we're doing data structures. Today, we discussed how to save square matrices column-wise with data structures. The teacher said that after the first few steps where you declare the structure, allocate the matrix, free it and get the dimension (which mostly make sense to me I think), you have to "get" and "set" the matrix by putting in something like

Code:
void setMatrixEntry(Matrix* A, int i, int j, double Aij) {
A->entries[i+j*A->m] = Aij;
}

[Code]....

View 7 Replies View Related

C++ :: Saving Unicode Data To TXT File

Sep 13, 2013

I have a problem when i try to save unicode to a .txt file.

I need to store in a file names that will have letters like "ăĂâÂșȘțȚîÎ"

wchar_t name []=L"ăĂâÂșȘțȚîÎ";
FILE* fang;
fang= _wfopen( L"test.txt",L"wt+,ccs=UNICODE");
fwprintf (fang, L"%ls ",name);

When i open my text file i get this: ??âÂ????îÎ

if i use
fang=fopen("test.txt","a");
I get the same result

and for
fang=fopen("ang.txt","a,css=UNICODE");
I get a runtime eroror "invalid file open mode"

View 2 Replies View Related

C++ :: Saving Array Data Into Text File

Dec 4, 2013

I have a program that saves all information temporarily into memory (into the array), however, I need a permanent save solution. I have the full program working correctly, formatted perfectly, but it's missing the file array to file output.

Essentially, whenever I'm presented with the menu I'll be able to add entries, search by last name, show the entire list, and exit and save. Whenever I select option 4 the program should save to a file "address_book.txt". Whenever I reload the program, it should load from "address_book.txt" and populate the array with the preexisting data.

My question is focused on how and where I should implement the file output. What I have thus far:

#include <iostream>
#include <string.h> //Required to use string compare
#include <fstream> //Eventually used to store array into file
using namespace std;
class AddBook{

[Code] ....

View 5 Replies View Related

C# :: Access Database Connection And Saving Data

Mar 17, 2014

I want to connect an access database (.mdb) to my Windows Forms application - this I can do and I have no problems viewing my table in server explorer.

Some code example or template that I can use as a base to learn from - I have literally trawled Google and Youtube and cannot find what I am after.

What I want to do is have a basic form, 2 text boxes and a button to save the data to my database.

FirstName and LastName are the 2 boxes.

View 6 Replies View Related

C++ :: Saving RGB Pixel Data Of JPEG Image In 3D Array

Jan 6, 2015

I need to save RGB values of each pixel in a 3D array A[width][height][3]. I found a code online that transfers the bytes into an array but I cant understand how bytes are saved them so i could transfer them into an array. The truth is I dont know much about working with images at all so i have a problem working on them. How to transfer the RGB data from an .jpeg image into a 3D array? This is my code so far:

#include <iostream>
#include <jerror.h>
#include <jpeglib.h>
using namespace std;
int main(){
FILE *pic = fopen( "image.jpeg", "rb+" );

[Code] .....

View 6 Replies View Related

C++ ::  Saving PNG File In Console Program / Losing Data?

Jul 18, 2013

I am working on a project that uses a web service to extract a PNG image from a web server and save it on a local machine. It's done via a system call. I can get the output of the system call to a FILE but it appears to be losing data, most notably the PNG chunk names (IHDR/PLTE/IDAT/IEND, notably). (Unfortunately piping the output to an exterior file does not work through a system call.) The end result is ~6KB smaller than the file I am intending to retrieve.

This is the code I'm using (adapted from other material I found via searches here):

ofstream png;
png.open(/*outputfile*/, ios::binary);
FILE* fp = _popen(/*SYSTEMCALL*/, "rb");
string responseString;
if(fp != NULL) {
char a[100];
while(!feof(fp)) {
fgets(a, 100, fp);
responseString += a;
}
}
_pclose(fp);
png << responseString;

Am I missing something or just doing it wrong?

View 11 Replies View Related

Visual C++ :: Analyze Bitmap - Concept For Saving Data

May 18, 2014

I would like to create program which will analyse bitmap so would need good concept to save data. I am interested about the theory and I realize that i must to think this carefully because bad concept could create insufficient memory or inefficient program. Basically I want my program work with HSV or HSL model so I would need to convert the bitmap to HSL, but I am not sure if I should convert it first and then analyse all pixels or should I start to analyse the bitmap and make the conversion to HSL during it. But my main question is what method to choose to save the data in memory.

Even that I would start with very small, it should work also with bigger image like image having 1200 or even 4200 px on height. So the program should first analyse all columns of pixels in the image so for example 1200x800 px image has 1200 columns. So I would like to know if is it possible to create such object which would have such structure like this

Obj->basicColumnData->black->columns[name]->group

and in the place of columns should be placed data for every column. I would look for groups of pixels in the column, so in the result the column x could bear e.g. 500 groups of information and every group should contain the range of pixels e.g. group 1 should contain y value from 0 to 20, group 2 should contain value from 25-27 and so on. So I would create 1200 columns bear many of groups. This would be contained in "black" or "white" member to contain the data. This is just simplified idea, but the whole object should contain next data not just basicColumnData... So there should be another members bearing information calculated from the selected data.

So my question is what kind of method of saving data use for this? Should I use heap and dynamic allocated memory or should I create custom class, which will define every member, but these members will have to be dynamic memory? With the dynamic memory is there problem that there could be not enough memory to create such big object?

View 5 Replies View Related

C Sharp :: Saving Data In SQL Server Parameter Error Showing

Jun 1, 2013

I have an application with general customer detail.

It has TextBox and radio button.

First I have used if statement then code but on first step is working fine then error is showing.

try
{
if (textBox1.Text == "")
{

[Code].....

View 5 Replies View Related

C :: Can't Seem To Receive UDP Packets

Jun 2, 2013

I'm trying to get a UDP server working and just can't seem to get it to read in any UDP packets. I can see the packet coming in on the correct interface and port from tcpdump, but my program never logs that it got the data.

I just keep getting a log showing that my recvfrom timed out. I'm pretty sure I'm setting everything up correctly.

Code:
int create_listen_socket() {
struct sockaddr_in si_me;
int sock_fd;
struct ifaddrs * ifAddrStruct=NULL;
struct ifaddrs * ifa=NULL;
void * tmpAddrPtr=NULL;
struct timeval tv;

[Code] ....

View 1 Replies View Related

C++ :: Packets And Tcp Simulation?

Nov 24, 2014

I have to write a program to take packets of information destined for certain ports then provide the current message using the packets I've gotten so far. Packets can come out of order, so when asked for the message, packets that haven't arrived yet are skipped and the next packet is appended. After giving the message, I have to delete all the current packets as well as ones that are received late, after the packets that were supposed come after the late packet were already provided in the message.

Data:Up to 1000 ports, numbered 0-64000, and each message can contain up to 1000 packets.

View 2 Replies View Related

C# :: Sending X-AMF Type Packets

Jan 10, 2015

create BOT that adds friends on one of Chat websites.

Im using C#

On website there is a button that adds user to friends

<li class="friend"><a href="javascript:void(0)">Add Friend</a></li>

I captured packet that is sended to server then that button is clicked

POST (info hided)/amfgateway.php HTTP/1.1Host: (info hided)
Connection: keep-alive
Content-Length: 52

[Code].....

It apears that this is AMF(Action Message Format) type packet Content-Type: application/x-amf it is in binary and this complicates things a little because I cannot send it with regular httpwebreqeuest class(Or I think so)

I used Fiddler4 with AMF plugin to check what data was passed with that packet

It apears that these numbers under content / 0 are User-id that is needed to add user to friends

I did a research with little success finding any usefull examples. I just found that there is a library for FLEX/FLASH remoting called fluorinefx and this should do the job but when I opened documentation it seems little too complex for me.

View 2 Replies View Related

C++ :: UDP Client Stop Receiving Packets

Jul 22, 2012

I have a simple UDP client that should be able to send and receive packets. It does its job, however if there are no packets received for a while it stops listening for any new packets and I'm not sure what's causing it.

This is my code:

#define WIN32_LEAN_AND_MEAN
#include "Client.h"
#include <winsock2.h>
#include <ws2tcpip.h>
#include <vector>
#include <sstream>
#pragma comment(lib, "Ws2_32.lib")

[Code] ....

View 1 Replies View Related

C :: Program To Sniff WiFi Packets Without Using LPCap

Feb 5, 2015

I have a requirement to sniff the wifi packets. There are examples available which does the sniffing using pcap functionality. I need a C program which will sniff the wifi packets without using pcap functionality..

Code:

#include<pcap.h>
#include<stdio.h>
#include<stdlib.h> // for exit()

[Code].....

View 13 Replies View Related

C++ :: Generating Poisson Arrivals - Size Of Packets

Jan 30, 2015

There is something I didn't understand. I use the sample given from the cpp reference to generate numbers:

const int nrolls = 10; // number of experiments

std::default_random_engine generator;
std::poisson_distribution<int> distribution(4.1);

for (int i=0; i<nrolls; ++i){
int number = distribution(generator);
cout<<number<<" "<<endl;
}

(original code: [URL] ... )

This outputs: 2 3 1 4 3 4 4 3 2 3 and so on... First of all what those numbers mean? I mean do I have to sum them to create timing? For example: 2, (2+3)=5, (5+1)=6, (6+4)=10,..., and so on..

Secondly, my real question is, I need to produce both random arrivals for network packets and the size of packets. I mean, when the packets come and if packets come, what are the size of packets? How can I do that? I need something like that: [URL] ...

View 1 Replies View Related

C++ :: Data Corruption In Vector

May 2, 2013

I have this code that is supposed to store numbers in one vector and another vector stores pointers to the values in the first vector:

#include <iostream>
#include <algorithm>
#include <sstream>
#include <cstring>
#include <vector>
#include <cstdio>

[Code] ....

However, when I print out the values stored by the pointer vector, the first 2 values are not the same as what the input was. I have tried it with 4 - 10 values and always, the first 2 are not the same as the input but the rest are. I tried printing out the values as they are stored in the vector in the first for-loop and it seems to contain them all, but after that first for-loop, when I try to print *station.front(), it is now changed to something else.

input:
4
1231 234354 4544343 121312

output:
34144320 0 4544343 121312

input:
6
123 2435 353 12221 356567 4544452

output:
21704768 0 353 12221 356567 4544452

View 9 Replies View Related

C++ :: How To Push Data Into The Vector

Apr 20, 2013

How can push data into the vector <list<Edge>> adjList? adjList[n].push_back (e);//gives error.

struct Edge {
int from_node_number;
int to_node_number;
int weight;
};
vector <list<Edge>> adjList;
Edge e;
for (int n=0; n< graph.size(); n++)
adjList[n].push_back (e);

View 6 Replies View Related

C++ :: What Data Structure Does A Vector Use

Dec 14, 2013

Does it use Linked List or Dynamic Array?

I want to know this because if I happen to want to use a lot of insertions and deletions then it is more efficient to make use of Linked List instead of Dynamic Array.

While, if I happen to want to just access random parts of the Array, then Dynamic would be more efficient.

I want to make a 2D game using SDL engine and I need to check whether or not an object is colliding with a list of other objects. (because there would be more then one objects on the map.)

Since I would simply be accessing each object sequentially to check whether or not the object is colliding with another the object in question, and since any of those objects could "die" and be deleted at any time, it makes more sense to use Linked List then a Dynamic Array.

View 8 Replies View Related

C++ :: How To Only Take Partial Data From Vector Slot

Apr 25, 2013

Suppose I have this vector it contains dates example

Vector.Dates [slot 1][slot 2] [slot 3] etc...

anyways slot 1 contains [ 05282013]
slot 2 contains [07032015]

I want to split the data it contains into 3 other locations How do I do that???

like vector.1[05][07]
vector.2 [28][03]
vector.3[2013][2015]

How do you only take partial data from a vector slot?

View 1 Replies View Related

C/C++ :: Vector As A Member Data Of Class

Dec 30, 2013

If I want a class with a vector data member, can I specify it as follows?

std::vector< bool > integers( 101 )

I'm having some problems when compiling code.

View 3 Replies View Related

C++ :: Putting Data From TXT File Onto Vector Of Class

Oct 18, 2014

I am having trouble putting data from a txt file onto a vector of a class. For instance.

class employee{
setname(string) {
some code
} getname () {
some code
} setid(int)

[Code] ....

How would use my setname function in my class using my vector? I tried doing vec[num].setname(tempname) but it doesn't work. I know it does not work because I have to use .push back for a vector but I don't know exactly how to pushback using the set name function call.

View 10 Replies View Related

C++ :: Compare Data Members Of Objects Store In Vector

Mar 6, 2014

Overview of problem : I am using std::vector to hold objects of Subject. Now this vector contains lots of objects( with lots I mean 10-20 objects at max) . These objects have string member values like category and sub_category. Both category and sub_category can have string which can be same of other objects's sub_category & category.

Issue: Now I want my std::vector to have only those objects whose's sub_category are unique. If category is not unique that's not a problem .

Secondly if we found 2 objects having same sub_category then we have to delete one of them from the vector. we will delete it based on some rules example

Rules for deleting are if

i) instance of Subject ->category = " Land " OR if category = "Jungle" then delete other duplicate object ,
ii) if above condition doesn't match then delete either of them.

I am wondering , how would I compare the sub-items from the vector . For example. I have class say Subject

class Subject {
public :
// some constructors,
// functions to get ., set category and sub category
std::String get_sub_category()
std::string get_category();
private:
std::string category;
std::string sub_category;
}

I have vector which stores object of Subjects. Example : vector<Subject> copy_vector;

Now what I want is to delete the object from vector that has same sub_category I am not looking for source code buT i need a starting point,? Example:

copy_vector[0] = Animal object that has sub_category Tiger
copy_vector [1] = Animal object with Lion as sub category
copy_vector[2] = Forest object with sub_category Tiger

What I want is to based on some conditions(which I can do ) remove either Forest or Animal object containing Tiger. But for that how would I do comparison? I have written the function and have checked it.

std::vector< Subject >copy_vector;
// copy_vector contains all the objects of Subject with redundant sub_category
for( std::vector< Subject >::iterator ii = copy_vector.begin() ; ii != copy_vector.end() ; ++ii ) {
sub_category = ii->get_sub_category();

[code] ....

View 1 Replies View Related

C++ :: Combine Multiple Vector Containing Binary Data To String?

Mar 16, 2012

Two questions:

1. I have some vector<unsigned char> containing binary data. I would like to combine them into one std::string. How is the correct way to accomplish this?

This is my best guess for sample code:

Code:
vector<unsigned char> data; //conatins some data
vector<unsigned char> data2; //contains more data
string temp(data.begin(), data.end());
temp.append(data2.begin(), data2.end());

Will this code work with binary data, or will it null terminate?

2. A similar problem.. I have some unsigned char* variables, and I want to combine them into one std::string. How can I accomplish this? will the member append() work here? or will it null terminate? Something like:

Code:
unsigned char* data; //conatins some data
unsigned char* data2; //contains more data
string temp(reinterpret_cast<const char*>(data));
temp.append(string(reinterpret_cast<const char*>(data2)));

Will the above sample code work without null termination?

View 4 Replies View Related

C/C++ :: Statistical Analysis Of Vector Data Set Of Integers - Frequency Distribution?

Feb 16, 2014

I am working on my second c++ project that is a statistical analysis of a vector data set of integers. I created a struct called range with a maximum value, minimum value and count for occurrence. The frequencies are stored in a vector<range>.

I have tried messing around with the increment to get the high range test above the maximum element, though my ranges cumulatively increase by 9.9. I'm not sure how the professor's program has the distance between high and low ranges as 10 instead of 9.9, which is the increment. I'm also unsure why half way through his buckets, the ranges appear as 9.99 briefly and then return to 10 after (40.00 - 49.99 then 49.99 - 59.99). I feel like I am missing something very obvious on line 04 or 10 in my code.

Here is the code for the frequency that accepts a vector reference for my data set of integers.

void frequency(vector<int>& data_set){
double max = findMax(data_set);
double min = findMin(data_set);
double increment = (max - min) / 10;
double percentage = 0.0;

[Code] ....

View 1 Replies View Related

C :: Parsing Char Array To Array Of Struct To Process Packets

May 28, 2013

I wrote this simplified version of a program i am writing that parses data in UDP packets. In the process of doing so i pretty much answered all my questions and fix all the problems i was having.

decodeSystemMap function will be in loop, and will proccess packets that have mostly the same data, only a few items will be added or changed or deleted.

whats the best way to check if there are any new, deleted, or removed items in the packet and only modify those?
Is there anything unsafe / dangrous about the way the code is now?

Code:
/* * File: main.c
* Author: david
*
* Created on May 23, 2013, 11:57 AM
*/

#include <stdio.h>
#include <stdlib.h>

[Code] ....

View 4 Replies View Related







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