|
Hi
I am looking for someone who can advise me and show an example of how to create a named pipe - one in and one out - with data stream.
To elaborate a little, I need to create a named pipe connection which will pass textual data from a desk top PC to an external device, which will be attached via USB cable. I need two named pipes - one to pass data down to the device and the other pipe to pass messages back to the PC from device.
Can anyone provide any help or example code for me, please?
|
|
|
|
|
AndyASPVB wrote: create a named pipe
you mean like this?[^]
Why is common sense not common?
Never argue with an idiot. They will drag you down to their level where they are an expert.
Sometimes it takes a lot of work to be lazy
Individuality is fine, as long as we do it together - F. Burns
Help humanity, join the CodeProject grid computing team here
|
|
|
|
|
Hi
I have done in Win32dll (c++) project and i have used it in C#, using Dllimport[]
One function update the data stream in one thread(running program)
Another function receive the same data stream in another thread(another running program)
You can use
CreateFileMappingA - to create and update the data stream
OpenFileMapping - to read the data stream.
these function are available in winsock2.h
|
|
|
|
|
named pipe is always used in vc, c++ program.
if you want to use it in c# program.
consider to use win32 Api to create it.
//sever
CreateNamedPipe 'create a named pipe
ConnectNamedPipe 'listen the client connect request
ReadFile 'get client's data
WriteFile 'send client's data
DisconnectNamedPipe 'close the named pipe
CloseHandle 'close the named pipe's handle
//client
WaitNamedPipe 'wait a named pipe to use
CreateFile
ReadFile
WriteFile
CloseHandle
modified 27-May-14 5:29am.
|
|
|
|
|
I have been trying to get the this to work and have been successful when using tiff files that have certain compression ilke LZW however I cannot get a tiff file that has compression JPEG Original TIFF 6.0 compression set for it. In fact I cannot bring up this tiff in windows picture and fax viewer! Has anyone else run into this?
Mondis
|
|
|
|
|
If windows can't read it, then the codec in question is not supported by windows in general, and that's probably why iTextSharp can't read it either. That means you need to find a library that includes that codec, in order to work with those images.
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
I have read somewhere that it is possible to remove the tiff header as the file I am working with is basically a JPEG. Do you have any idea how to do that. The example code I saw was written in spanish. I can open the image using a file stream and read that into a byte array, but I don't know how to find the header information and strip it out.
Thanks for any info!
Mondis
|
|
|
|
|
It's a jpeg inside a tiff ? You'd have to look for the file format online to work out what bytes you need to remove, in order to be left with the JPEG. It may be fixed number, or it could be variable and you'll need to parse it to work it out.
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
I believe it is a JPEG inside a TIF. It's a weird thing in an application I used to work on but didn't handle the Imaging software so I don't know anything about it. I am just hoping to find something that will do the trick.
Mondis
|
|
|
|
|
you mean Tiff picture to PDF format?
try to use 'image.save()' in C# to change picture's format.
modified 27-May-14 5:29am.
|
|
|
|
|
Thanks for the tip however it didn't work. The issue is definitly the compression type used to create the tiff image. I was able to resolve the issue using the original program that created the tiff to safe it with a different compression and then convert to Tiff.
Thanks
Ray
Mondis
|
|
|
|
|
how can I calculate the total hours and minutes between two DateTimes? I tried this code but it's getting it correctly..
<pre>TimeSpan time_difference = DateTime.Now - Convert.ToDateTime(gridComputers.GetRowCellValue(i, "start_time"));
double usage_hours = time_difference.TotalHours;
double usage_minutes = usage_hours - ((int)usage_hours * 60);
string total_usage = String.Format("{0}h {1}m", (int)usage_hours, (int)usage_minutes);</pre>
|
|
|
|
|
jrahma wrote: how can I calculate the total hours and minutes between two DateTimes? I tried this code but it's getting it correctly..
TimeSpan time_difference = DateTime.Now - Convert.ToDateTime(gridComputers.GetRowCellValue(i, "start_time"));
double usage_hours = time_difference.TotalHours;
double usage_minutes = usage_hours - ((int)usage_hours * 60);
string total_usage = String.Format("{0}h {1}m", (int)usage_hours, (int)usage_minutes);
If it is getting it correctly, then I don't see you have a problem!
Actually I do, but never mind. Why are you playing with
double usage_minutes = usage_hours - ((int)usage_hours * 60);
Why not use
double usage_minutes = tume_difference.TotalMinutes;
See example here[^]
No trees were harmed in the sending of this message; however, a significant number of electrons were slightly inconvenienced.
This message is made of fully recyclable Zeros and Ones
|
|
|
|
|
OriginalGriff wrote: double usage_minutes = tume_difference.TotalMinutes;
I don't believe that would give the results the OP is looking for. For instance with a TimeSpan representing 1.5 hours, TotalMinutes = 90. I believe what he wants is 1h 30m
only two letters away from being an asset
|
|
|
|
|
Makes sense! So use:
double usage_minutes = (double) time_difference.TotalMinutes % 60;
No trees were harmed in the sending of this message; however, a significant number of electrons were slightly inconvenienced.
This message is made of fully recyclable Zeros and Ones
|
|
|
|
|
what is wrong with TimeSpan.Hours and TimeSpan.Minutes?
Luc Pattyn
Have a look at my entry for the lean-and-mean competition; please provide comments, feedback, discussion, and don’t forget to vote for it! Thank you.
Local announcement (Antwerp region): Lange Wapper? Neen!
|
|
|
|
|
Luc Pattyn wrote: what is wrong with TimeSpan.Hours and TimeSpan.Minutes?
I don't like the colour.
That's my excuse, and I'm sticking with it.
Nothing to do with my forgetting about them, no siree!
No trees were harmed in the sending of this message; however, a significant number of electrons were slightly inconvenienced.
This message is made of fully recyclable Zeros and Ones
|
|
|
|
|
Unfortunately, TimeSpan is sealed so you can't simply inherit and modify some aspects. If you don't like its color, you'll have to redo everything from scratch. Make sure to implement full skinning capabilities, compatible with XP, Vista and 7.
Luc Pattyn
Have a look at my entry for the lean-and-mean competition; please provide comments, feedback, discussion, and don’t forget to vote for it! Thank you.
Local announcement (Antwerp region): Lange Wapper? Neen!
|
|
|
|
|
|
Your problem is in usage_minutes. You subtract 60h from h, which gives you a total minutes value of -59 * usage_hours. What you should be doing is something like time_difference.TotalMinutes % 60 (excluding freaky stuff like leap seconds, etc)
|
|
|
|
|
'TotalHours' is not the same to 'Hours';
'TotalMinutes' is not the same to 'Minutes';
//for example
private string DateDiff(DateTime DateTime1, DateTime DateTime2)
{string dateDiff = null;
TimeSpan ts1 = new TimeSpan (DateTime1.Ticks);
TimeSpan ts2 = new TimeSpan (DateTime2.Ticks);
TimeSpan ts = ts1.Subtract(ts2).Duration();
dateDiff = ts.Days.ToString()+"days"+ ts.Hours.ToString()+"hours"+ ts.Minutes.ToString()+"minutes"+ ts.Seconds.ToString()+"seconds";
return dateDiff;
}
modified 27-May-14 5:29am.
|
|
|
|
|
I would like to implement factory methods to transfer data between the gui controls and my dataobjects. The gui controls can be ASP.NET web controls or Windows controls and I have a utility library for each environment. The dataobjects can run in either environment and should know nothing about which it is in.
So what I would like to happen is that when the Web utility library is loaded the webgui<->do bridges are registered and when the Windows utility library is loaded the wingui<->do bridges are registered. That way the dataobjects can send/receive data from the gui without knowing which gui it is.
It seems like such a basic requirements for factories. Is there a way to do this?
|
|
|
|
|
Maybe have a look here[^]
"Inversion of Control containers allow you to achieve loosely coupled designs and they handle dependency and configuration management when you, or a class in your system, request a service to say, send e-mails, you will get an instance ready to be used."
only two letters away from being an asset
|
|
|
|
|
I have a third party library which i have added to the skip verification list, using sn, on my computer.
I wanted to know whether the application (after deploying it on some other computer) will run?
Do i have to perform some other tasks after the deployment (setup)?
|
|
|
|
|
Yes it will work ,
SN protected the Application Exe bytes from begin modify.
I know nothing , I know nothing ...
|
|
|
|