hi,
i'm going to develop one application to communicate rs232 or by using c++ or c# language.
can u give me a snippet code or url for it?
any suggestion will be welcome!!!
regrads
so
hi,
i'm going to develop one application to communicate rs232 or by using c++ or c# language.
can u give me a snippet code or url for it?
any suggestion will be welcome!!!
regrads
so
Ok, so to start with, there is no STANDARD way to communicate on a serial port in C. It is all depending on the OS and hardware you have to work with. So if you tell us what OS and hardware you have, we MAY be able to help you (but of course, it is also possible that we can't, if the hardware or OS is really unusual).
--
Mats
Compilers can produce warnings - make the compiler programmers happy: Use them!
Please don't PM me for help - and no, I don't do help over instant messengers.
Go with C#, can't be any easier:
Code:using(var Port = new System.IO.Ports.SerialPort("COM1", 9600, System.IO.Ports.Parity.None, 8, System.IO.Ports.StopBits.One)) { Port.Open(); Port.Write("Hello"); }
MagosX.com
Give a man a fish and you feed him for a day.
Teach a man to fish and you feed him for a lifetime.
Yes, and it's not NECESSARILY much harder in C++ or C. You may need two or three lines to open the port, then you just write to and read from the port - in some OS's. Presumably C# isn't really viable for real-time OS systems that do not support files and such things, so in that case, it's more C or C++ only.
Obviously, in any language, it gets more complex if we have to deal with transmission errors, time-outs due to other end dropping out, etc, etc, which is usually necessary for REAL systems.
But giving examples of how it's done in one or another environment is pointless if the environment that the original poster is asking about is one that is not at all similar - and it doesn't matter if we give a simple or complex example.
--
Mats
Compilers can produce warnings - make the compiler programmers happy: Use them!
Please don't PM me for help - and no, I don't do help over instant messengers.
the previous principal software engineer at my company picked these out:
http://marshallsoft.com/
i've used them for years. their documentation could be a lot better, but i've never had any real problems with it.
I quite like this site - http://www.lvr.com/serport.htm
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
If at first you don't succeed, try writing your phone number on the exam paper.
i appreciate your help.
and thx, Magos.
but i want to get some code about 485 communicate.
can u help me?
regards
so
Go with C/C++ its even easier than that
For more detailed control see http://msdn.microsoft.com/en-us/library/ms810467.aspxCode:FILE* pFile = fopen("COM1:" , "w+b"); fprintf("Hello World\n",pFile);
Last edited by abachler; 02-21-2009 at 03:42 PM.
MagosX.com
Give a man a fish and you feed him for a day.
Teach a man to fish and you feed him for a lifetime.
thank u for your help.
i need one more thing.
it's usb communication.
i bought one device(fingerprint) and i want to develop program to use this one using rs232/485 or usb.
i finished already developing program via rs232 communicating.
and i'd like to communicate via usb bus.
how can i do it?
best regards.
p.s.
my english is no so good.
thx
USB communication is much harder. Unlike RS232 it's not a port but a bus.
You have to google some info.
MagosX.com
Give a man a fish and you feed him for a day.
Teach a man to fish and you feed him for a lifetime.
you should also make sure you back up your files before embarking on a usb driver.
the equipment i use that uses a USB connection is VERY finnicky.
for example, providing the wrong ADC code would cause the whole OS to lock up on one device.
on another, closing an invalid device handle gave me 'the blue screen of death' :|
of course, these are problems with the OEM's code and not with USB, but you should be very careful.