|
I have created PDF without using those libraries. I have finished it in 5 days.... Thanks for your comments.
|
|
|
|
|
i have seen many artical only to upload a image...
or by using database.
|
|
|
|
|
And how is that different from what you want to do?
The source of the data should be pretty much irrelevant here...
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
|
|
|
|
|
I found example here: http://forums.codeguru.com/showthread.php?182234-serial-ports-C[^] for serial communication on C# using PInvoke calls.
One question I have is that DCB structure they use here:
[StructLayout(LayoutKind.Sequential)]
public struct DCB {
public int DCBlength; public int BaudRate;
public uint flags;
public ushort wReserved; public ushort XonLim; public ushort XoffLim; public byte ByteSize; public byte Parity; public byte StopBits; public char XonChar; public char XoffChar; public char ErrorChar; public char EofChar; public char EvtChar; public ushort wReserved1; }
You can see they have commented out the `CTS`, `DSR`, `RTS`, `DTR` and `XON/XOFF` out flow control parameters. But I need to be able to set these parameters. How do I modify this structure such that I can use these parameters also? Should I just uncomment the commented fields?
PS. Also, does the implementation I linked look reasonable to you?
|
|
|
|
|
No, you don't uncomment them - they are bit fields - which mean s that each of the "names" refers to a single bit within the flags element: fBinary is bit 0, fParity is bit 1, and so on.
If you uncomment them, you will get totally the wrong structure size.
C# doesn't have bit fields - so you need to define const values for each bit value and set it on and off using the C# &, |, and ~ bitwise operators.
Is there a good reason for not using the C# SerialPort implementation instead?
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
|
|
|
|
|
Can you please show me a sample how I would use that structure in C# so that I can set DSR, DTR, RTS, CTS and Xon/Xoff parameters to true or false?
PS thing is I have C++ implementation of serial communication and need to translate to C#. C#'s SerialPort doesn't allow to fine tune as many parameters as C++ does, e.g., see here: http://stackoverflow.com/questions/32859276/rewrite-serial-port-communicationf-rom-c-to-c-sharp[^]. What is the way I should approach it you think?
I will appreciate if you can show me how to use that DCB in C# so that I can set all (DSR, DTR, RTS, CTS and Xon/Xoff) parameters.
|
|
|
|
|
You are kidding, right?
Use the C# bitwise operators:
private const int Bit2 = 4;
...
int myFlags = 0;
myFlags |= Bit2; // Set bit 2.
myFlags &= ~Bit2; // Clear bit 2.
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
|
|
|
|
|
Why am I kidding ?
how do I know which bits in the new C# structure:
[StructLayout(LayoutKind.Sequential)]
public struct DCB {
public int DCBlength; public int BaudRate;
public uint flags;
public ushort wReserved; public ushort XonLim; public ushort XoffLim; public byte ByteSize; public byte Parity; public byte StopBits; public char XonChar; public char XoffChar; public char ErrorChar; public char EofChar; public char EvtChar; public ushort wReserved1; }
correspond to parameters like CTS, DSR, RTS, DTR, Xon/Xoff from the original structure?
PS. Do you think I should give a try maybe to SerialPort and if doesn't work revert to this PInvoke implementation?
|
|
|
|
|
If I were you, I'd look for an implementation such as this[^].
|
|
|
|
|
Try the version of this structure from pinvoke.net, which provides properties to get and set the individual bits:
http://pinvoke.net/default.aspx/Structures/DCB.html[^]
The SerialPort class[^] would be a better choice for .NET code. It gives you friendly properties for all of the settings from the DCB struct.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
modified 30-Sep-15 8:42am.
|
|
|
|
|
|
Yes, you should be able to replace the DCB structure from that thread with the version from the pinvoke.net site.
P/Invoke doesn't care about methods, properties or events on a structure. It only cares about the raw bytes passed across. So long as the fields you're using produce the right bytes to send to the unmanaged method, it will work.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
First I will try I guess with SerialPort methods. If some issue occurs, then I think I will revert to that PInvoke approach in that thread
|
|
|
|
|
Hi is there anyone who can give me a link where can i download working remote desktop view using c# together with the source code
PS: remote desktop viewer using local area network
|
|
|
|
|
That isn't what we are here for: we are not a Google search assistant, and we don't provide full systems on demand.
Start with Google, and see where you get.
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
|
|
|
|
|
Do google for it
|
|
|
|
|
Hi,
I am trying to send a *.xlsx file as an email attachment in #c for that we write the below code
Attachment item = new Attachment(fileName.xslx,MediaTypeNames.Application.Octet);
item.TransferEncoding = System.Net.Mime.TransferEncoding.QuotedPrintable;
mail.Attachments.Add(item);
mail.IsBodyHtml =true;
mail.BodyEncoding =Encoding.UTF7;
mail.HeadersEncoding =Encoding.UTF7;
stmp.Send(mail);
By doing this in some machines we are able to send the mail successfully,but in some machines we are not able to send and also from those machines we are getting a mail with junk characters as body of the mail.
Please help us if anybody knows anything related to this(we are suspecting it might be machine settings problem,but we dont know what settings we need to change)
|
|
|
|
|
Don't create a duplicate thread - update your first one
=========================================================
I'm an optoholic - my glass is always half full of vodka.
=========================================================
|
|
|
|
|
Why are you using UTF7? That's probably the issue. You should be using UTF8.
There are only 10 types of people in the world, those who understand binary and those who don't.
|
|
|
|
|
Hi
We tried with UTF8 also that is also not working,but strangely as mentioned above even with UTF7 it is working on some machines
|
|
|
|
|
I have this C++ code for setting timeouts on serial port
COMMTIMEOUTS *timeouts = new COMMTIMEOUTS ;
memset(timeouts, 0, sizeof(COMMTIMEOUTS)) ;
timeouts->ReadIntervalTimeout = ReadIntervalTimeout ;
timeouts->ReadTotalTimeoutMultiplier = 5 ;
timeouts->ReadTotalTimeoutConstant = readTimeOut ; timeouts->WriteTotalTimeoutConstant = 0 ; timeouts->WriteTotalTimeoutMultiplier = 2*BaudRate/8 ;
const bool ret = SetCommTimeouts(*hDev, timeouts) != FALSE ;
delete timeouts ;
m_currentTimeOut = readTimeOut ;
I need to rewrite this in C#. For SerialPort class I found these properties:
_serialPort.ReadTimeout = 500;
_serialPort.WriteTimeout = 500;
Are they equivalent? It seems there are more parameters in play in the C++ code. How can I approach this? Or maybe other parameters are not needed? What is the best way to transform that C++ code to C#?
|
|
|
|
|
|
Not really, see on C++ there are more parameters about time out whereas on C# there is only 2. So it means I can't do exact mapping...?
|
|
|
|
|
user20044 wrote: whereas on C# there is only 2. Yes exactly, C# is a much easier language than C++ and is a high level language; whereas, C++ is a low-level language. C++ will likely always give equal to or greater control to the developer.
There are only 10 types of people in the world, those who understand binary and those who don't.
|
|
|
|
|