Programming :: Read Unknown Data Length From Usb Pipe?

Aug 12, 2010

I've written a usb device driver and a program that sends and receives data over the bulk pipe. The read function sometimes returnsI'm reading an unknown amount of data. However, using a usb tracker I can see that the correct data is being sent.The error only occurs sometimes.I expect that the read function is told to read more data that it receives it would fail and return -1, however if this was the case then every read call would fail.

View 4 Replies


ADVERTISEMENT

Programming :: Read A Blank Line Ie A String Of Length 0?

Apr 19, 2010

in gcc how to read a blank line ie a string of length 0.my code:

Code:
#include<stdio.h>
#include<string.h>

[code]...

View 3 Replies View Related

Programming :: Getting The Name Of The Process That Sent Data To A Pipe?

Feb 16, 2011

I am trying to automate some directory naming when we're manually running some scripts and are using tee to direct the output to a file (log). Right now this is what we do

Code:

./some_script.sh 2>&1 | tee /home/user/some_dir/logs/manual/some_script_20110216_1628.log

As a matter of laziness and keeping the log files consistently named, I'd like to create a function to pipe it to so that it's doing all the naming How I envision the command running

Code:

./some_script.sh 2>&1 | myfunc

And what the logfile name should look like (and in the right directory)

Code:

some_script_20110216-1628.log

I was thinking of adding a function to our profile to handle this. Just in testing I was trying to stream line right on the command line, but I'm having some difficulty in getting the name of the script that is pushing data over the pipe. Here is what I've tried

Code:

./some_script.sh 2>&1 | tee $(cd ../logs/manual; pwd)/$0_$(date +%Y%m%d)-$(date +%H%M).log

but that created a file named

"bash_20110216-1628.log"

View 3 Replies View Related

Programming :: Select() Call Does Not Detect Data In Pipe Between Parent And Child Program

Sep 23, 2009

i wanted to capture the stdout and stdin of a child process within a parent so that any output of child is sent to the parent and any input taken from the parent. code is simple enough and i have followed all code guidlines on the internet (some guidlines do differ also) my select call either hangs if i do not give a tmeout and with a timeout it returns 0 descriptors to be written to or read from:

below is the simple code for parent:

int main(void)
{
int outfd[2];
int infd[2];

[code].....

why select hangs without a timeout ... why can it not detect that the pipe is write ready i.e parent can write to it ... if it does not detect tha read pipe as having data...

View 5 Replies View Related

Programming :: Get Data From Serial Port Function Read() Blocks When Data Not Available?

Jun 11, 2009

I am using read() in c++ to get data from a serial port. However, if no data is available on the serial port the function blocks until dta arrives.Example code:

//------------------------------------------------------------
char m_readBuffer[255] = {0};
char* p_curChar = m_readBuffer;

[code]...

View 1 Replies View Related

Programming :: Data Directory In Automake - Data Is Always Read-only ?

May 9, 2010

I have some data files that should be distributed with my program. Using dist_pkgdata_DATA in Makefile.am, I get these files installed to /usr/local/data/share/package-name. The problem is that data is read-only, and my program needs to modify it. Playing with dist_sharedstate_DATA, dist_localstate_DATA, dist-data_DATA varibles, I got different installation directories, like /usr/local/com, usr/local/var, but data is always read-only.

How can I distribute modifiable data files with my package? I need some common directory for all users, or maybe local data in a user directory.

View 1 Replies View Related

Programming :: Handle A Broken Pipe Exception (SIGPIPE) In FIFO Pipe?

Mar 2, 2011

I've written a simple server in linux used fork to create a FIFO pipe.The server create two FIFO pipe.One for server read data from client and write data to client.Then another pipe for client read data from server and write data to server.When the server read data from a client used server-pipe and then write data to client.But ,if the client no read open the pipe,the server side write will be crashed because of a broken-pipe SIGPIPE. How to check whether the read side is opened?Or,how to catch the SIGPIPE,and then my server will still execute on,not crashed!!

View 5 Replies View Related

Programming :: Read Data From A Socket?

Aug 24, 2010

I need to read data from a socket but it should be always listening because data arrives continuously .. I thought something like this would do it but it doesn't work .... I already set the socket options before

Code: char databuf[1024];
int datalen = sizeof(databuf);
if(read(sd, databuf, datalen) < 0)
{

[Code]....

View 9 Replies View Related

Programming :: Possible To Open A Symlink (won't Follow) And Read Data From It?

Nov 9, 2010

I try to use open(2) system call, and I find one relevant flag: O_NOFOLLOW. But it will only return -1 rather than the symlink's file descriptor

View 5 Replies View Related

Programming :: Read Some Data From Controller Using Serial Port?

Aug 25, 2010

i want to try with a small application in linu in that i want to read some data from controller using serial port and i wanna transfor that data to another meachin in the network for this i want serial port interfacing programming as well as socket programming.

View 1 Replies View Related

Programming :: Serial Port Data Read Time Interval?

Oct 30, 2010

I am writing a C program which reads data over serial port. While reading data, if I send my data(which is a 13 byte structure) periodic with a period of 1 second for 10 times I read it without problem and I read the data 10 times as I sent and as I expectBut if I send data continuousuly(without any time interval between each sending) 10 times I can only read 1 of them(I can only read it once).

View 11 Replies View Related

Programming :: Debian Serial Port Read() Return Wrong Data?

Jul 6, 2010

I am implementing a simple serial protocol where my ARM9 board, running Linux is communicating to a slave peripheral board. The Master sends a 12 byte data stream and the peripheral board returns status in a 23 byte response. The serial port is opened in raw mode. It works perfectly on 44 reads; however, on the 45 read the data returned from the read() is incorrect. I've framed what's being sent on an oscope and it is correct.The coincidence is that 23 x 44 = 1012. It's as though the receive buffer is 1K and when I go past the boundary I get bad data. The read following the bad one is good again.I've tried flushing the buffer before reading but get the same result.Here's the port initialization code:

Code:
int initport(int fd)
{

[code]...

View 4 Replies View Related

General :: Read File And Pipe To Grep

May 26, 2011

I'm storing a list of strings in a file and would like to read the file and pipe each line returned to grep which in turn searches a directory for files containing the string.However this is not returning any output.

View 2 Replies View Related

Fedora :: FC14 - Rt_ioctl_giwscan. 6(6) BSS Returned - Data->length = 890

Nov 4, 2010

On my FC14 in /var/log/message i have a lot of erroe about rt_ioctl ..

[Code]....

View 1 Replies View Related

Red Hat / Fedora :: Invalid Compressed Data - Length Error

Jun 20, 2011

I have a something.gz file. When I type gunzip -c something.gz this commend open the file but at the end of the file I get an error message invalid compressed data--length error. Also if I type more at the and of this commend like gunzip -c something.gz | more, file would not open. It gives some meaningless characters.I want to open this file with more.

View 1 Replies View Related

General :: Bash Script To Read Csv File With Multiple Length Columns

Jul 27, 2011

I've searched everywhere and I can't come up with a good solution. For each line I need to find the average, min, and max. I've seen plenty of solutions where the number of columns is fixed, unfortunately for me these lines can get pretty large. My thought was to read each line individually into an array, loop through the array and find the avg, min, and max that way but i haven't had much luck. I can read each line using a while loop but I'm having trouble with the array part, or perhaps that's not the best solution?

View 14 Replies View Related

Networking :: Serial Port : Read Data, Not Reading Complete Data?

Mar 5, 2010

I have an application where I am sending data via serial port from PC1 (Java App) and reading that data in PC2 (C++ App). The problem that I am facing is that my PC2 (C++ App) is not able to read complete data sent by PC1 i.e. from my PC1 I am sending 190 bytes but PC2 is able to read close to 140 bytes though I am trying to read in a loop.Below is code snippet of my C++ AppOpen the connection to serial port

Code:
serialfd = open( serialPortName.c_str(), O_RDWR | O_NOCTTY | O_NDELAY);
if (serialfd == -1)

[code]...

View 5 Replies View Related

Programming :: How To Find Array Length In C

Jul 3, 2011

I would like to know how can I find array length in C .I have array of structure and I want to sent it to different functions and I want to have it's length (number of elements) each time I want to use it and I don't like to use any additional variable to pass the function for each of arrays that I pass to function.
How can I do that?

View 5 Replies View Related

Programming :: Calculate Length Of My Array?

Jun 30, 2010

I want to calculate length of my array, say Unix here.

Code:
[linux1@HMLINUX1 abc]$ declare -a Unix=('Debian' 'Red Hat' 'Suse' 'Fedora');
[linux1@HMLINUX1 abc]$
[linux1@HMLINUX1 abc]$ echo ${#Unix[@]}
5

This should be ideally 4, but somehow it is showing as 5. However, when I am removing the space as RedHat instead of Red Hat, it is working perfectly.

Code:
[linux1@HMLINUX1 abc]$ declare -a Unix=('Debian' 'Redhat' 'Suse' 'Fedora');
[linux1@HMLINUX1 abc]$ echo ${#names[@]}
4

View 4 Replies View Related

Programming :: Parse Files With Variable Record Length?

Aug 6, 2010

I would like to extract Room number, Lastname,Firstname,invoice (205880080),arrival date, departure date, and total(229.46). Can you at least give me a hint on how to proceed? I have tried a lot but I am stumped from the beginning.

***History***
Room: 124 B Payment: Bell/TRAVELSCAPE.COM
Lastname*FIT*,Firstname 4A, 0K, 0B Guest
Bell *205880080 FT
Bell *205880080 July 31, 2010

[Code]...

View 4 Replies View Related

Programming :: C/c++ Code Is Used To Parse Type - Length - Value Messages?

Feb 12, 2011

Does anyoe have any example c/c++ code that is used to parse type-length-value messages.

The only decent article I can find on the web is:
http://en.wikipedia.org/wiki/Type-length-value

Bur it does not give any examples of parsing etc..

View 1 Replies View Related

Programming :: Get "data Type" Of An "unknown Variable" In "C Language"?

Jun 13, 2009

I am going to write a function which will do different operation base on the data type of the input parameter.

I am using C (Pure C, not C++).

The problem is that I do not know how to get the data type of the input parameter in C Language.

Can anyone tell me how to do this.

View 8 Replies View Related

Programming :: Use Pipe In Excel Function?

Apr 13, 2010

In shell, I execute "./ffmpeg -f h264 - | xxx"

Now I hope use execl function to execute above operations,

I call execl("/bin/sh", "sh", "-c", "./ffmpeg -f h264 - | xxx");

but ffmpeg doesn't work, it seems that "|" pipe don't work.

how could I solve this?

View 1 Replies View Related

Programming :: BASH: Get PID Of First Command In Pipe

Aug 11, 2010

I understand that $! is the PID of a command. For example:

Code: #!/bin/bash
myprogram &
echo "PID of myprogram is $!"

I'd like to send the output of "myprogram" to both console and to a log file using the "tee" command but I also want to store the PID of "myprogam". Something like this:

Code: #!/bin/bash
myprogram | tee ./logfile &
echo "PID of myprogram is $!"

The problem is that $! is now the PID of "tee" rather than the PID of "myprogram".

View 3 Replies View Related

Programming :: Pipe Output To Gtkdialog?

Apr 5, 2011

For instance, suppose I want to pipe the output of ps -A to a gtkdialog table.

View 1 Replies View Related

Programming :: Pipe Output Of Ls To File?

May 3, 2011

I want to pipe the output of ls in a folder to a file (lets call it test.txt) but when i do so, but when i do ls > test.txt in test.txt there is also test.txt (logical

View 4 Replies View Related

Networking :: PING - Pipe 2 Versus Pipe 3

Apr 10, 2009

I'm doing ping between 2 RH servers through a VPN site2site tunnel and in some times I got in the result pipe 2 and another pipe 3 as I mark it in blue color below.

e.g.

64 bytes from 192.168.1.10: icmp_seq=0 ttl=128 time=0.229 ms
64 bytes from 192.168.1.10: icmp_seq=1 ttl=128 time=0.287 ms
64 bytes from 192.168.1.10: icmp_seq=2 ttl=128 time=0.278 ms

[code]....

What's the difference between pipe 2 and pipe 3 and what's the meaning of it?

View 1 Replies View Related

Programming :: Perl's Length() Counts Umlauts Multiple Times

Dec 14, 2010

I'm programming some skript to get statistical information about some texts. This includes calculating the mean of word lengths.Unfortunately, Umlauts count as two characters. In the example below the output is 9, it should be 6.

sincercly, Max

Code:
#!/usr/bin/perl
use POSIX;
use locale;
my $test = length("ABC���");
print $test;

View 4 Replies View Related

Programming :: Php/HttpRequest/https: A TLS Packet With Unexpected Length Was Received?

May 29, 2010

I'm working on an application that makes http requests using HttpRequest and it's been doing what I need so far without a problem. Now I need to make https requests as well and when I try to make the request, i get this error message:

Code:
Fatal error: Uncaught exception 'HttpInvalidParamException' with message 'Empty or too short HTTP message: ''' in /home/antoranz/waneesia/html/index.php:0 inner exception 'HttpRequestException' with message 'SSL connect error; gnutls_handshake() failed: A TLS packet with unexpected length was received. (https://www.paypal.com/)' in /home/antoranz/waneesia/html/index.php:104 Stack trace: #0 /home/antoranz/waneesia/html/index.php(0): HttpRequest->send() #1 {main} thrown in /home/antoranz/waneesia/html/index.php on line 0
What's going on?

The project: url

View 1 Replies View Related

Programming :: Directory Record Length Is Variable In Ext2 Filesystem?

Jan 7, 2011

The declaration for directory record length in ext2 filesystem is as follows:

Code:
#define EXT2_NAME_LEN 255
struct ext2_dir_entry_2 {
__u32 inode; /* Inode number */
__u16 rec_len; /* Directory entry length */
__u8 name_len; /* Name length */
__u8 file_type;
char name[EXT2_NAME_LEN]; /* File name */
};

Some say because the record is not in a fixed length so rec_len is the real record length. Why is the length of the array `name' not fixed? I thought C arrays like this should be fixed length. C99 has variable-length arrays, does this structure count on C99?

View 7 Replies View Related







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