Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ Library support » U++ Core » read/write to /dev/rtp is happening .. but a small problem
read/write to /dev/rtp is happening .. but a small problem [message #33784] Tue, 13 September 2011 14:02 Go to next message
Monty.mvh is currently offline  Monty.mvh
Messages: 31
Registered: July 2011
Location: Bangalore
Member
Hi,
I was able to perform read/write to /dev/rtp in upp using the below code structure..
#include <Core/Core.h>
using namespace Upp;

CONSOLE_APP_MAIN
{
	
	struct read
	{

		unsigned int status;
		unsigned int TimeOut;
	};

	read ReadArray;
	FileStream file;

	while ( 1 )
	{
		file.Open ( "/dev/rtp0",0 );
		file.Read (0, &ReadArray, sizeof ( ReadArray ) );

		Cout() << FormatInt(ReadArray.status )<< "\n";
    sleep(1);

	}
		
}


Here i used the class FileStream and the function file.Read();
To do this i had to do modifications in the header file stream.h
I changed the Class FileStream member function Read(); from Protected to Public.

But can i achieve the samething using class FileIn and its function Get();
I tried with the below code but did'nt get the incrementing pipe reading but got only a constant value repeating.
#include <Core/Core.h>

using namespace Upp;

CONSOLE_APP_MAIN
{

	struct read
	{

		unsigned int status;
		unsigned int TimeOut;
	};

	read ReadArray;
	FileIn file;

	while ( 1 )
	{
		file.Open ( "/dev/rtp0" );
		file.Get ( &ReadArray, sizeof ( ReadArray ) );

		Cout() << FormatInt ( ReadArray.status ) << "\n";
		sleep ( 1 );

	}

}
Re: read/write to /dev/rtp is happening .. but a small problem [message #33805 is a reply to message #33784] Thu, 15 September 2011 08:42 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
Monty.mvh wrote on Tue, 13 September 2011 08:02

Hi,
I was able to perform read/write to /dev/rtp in upp using the below code structure..
#include <Core/Core.h>
using namespace Upp;

CONSOLE_APP_MAIN
{
	
	struct read
	{

		unsigned int status;
		unsigned int TimeOut;
	};

	read ReadArray;
	FileStream file;

	while ( 1 )
	{
		file.Open ( "/dev/rtp0",0 );
		file.Read (0, &ReadArray, sizeof ( ReadArray ) );

		Cout() << FormatInt(ReadArray.status )<< "\n";
    sleep(1);

	}
		
}


Here i used the class FileStream and the function file.Read();
To do this i had to do modifications in the header file stream.h
I changed the Class FileStream member function Read(); from Protected to Public.

But can i achieve the samething using class FileIn and its function Get();
I tried with the below code but did'nt get the incrementing pipe reading but got only a constant value repeating.
#include <Core/Core.h>

using namespace Upp;

CONSOLE_APP_MAIN
{

	struct read
	{

		unsigned int status;
		unsigned int TimeOut;
	};

	read ReadArray;
	FileIn file;

	while ( 1 )
	{
		file.Open ( "/dev/rtp0" );
		file.Get ( &ReadArray, sizeof ( ReadArray ) );

		Cout() << FormatInt ( ReadArray.status ) << "\n";
		sleep ( 1 );

	}

}



It is really not a good idea. File expects regular files.

If you insist on using Streams, you would have to develop your own. Perhaps look at Cout() implementation for that...

Mirek
Re: read/write to /dev/rtp is happening .. but a small problem [message #33834 is a reply to message #33784] Sat, 17 September 2011 06:37 Go to previous message
Monty.mvh is currently offline  Monty.mvh
Messages: 31
Registered: July 2011
Location: Bangalore
Member
Thanks Mirek,
Thanks for the suggestion.
Previous Topic: Core: Null handling incoherent?
Next Topic: Linux and GetCurrentDirectory
Goto Forum:
  


Current Time: Sat Apr 27 22:04:59 CEST 2024

Total time taken to generate the page: 0.05094 seconds