Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Jan 9th, 2007, 7:08 AM   #1
hbe02
Hobbyist Programmer
 
hbe02's Avatar
 
Join Date: Mar 2006
Location: Lebanon
Posts: 148
Rep Power: 3 hbe02 is on a distinguished road
.NET serial USB communication

here is a question on serial communication .
in .NET framework 2.0 . you can use the serial port class to send/recieve bytes serially through the serial port of your PC .
Since im using a laptop, i do not even have a serial port.
so how can i use the USB port to communicate..? is there an alternative?

I have scanned for the serial ports available in my laptop with this method:
string[] ports = SerialPort.GetPortNames();
   
for(int i  =0 ; i < ports.Length ; i ++ )
{
    Console.Writeline(ports[i]);
}

the output is get is "COM3".

obviously i do not have COM1 or COM2 .. but what is COM3? where is it physically? can i use this instead of communicating using the USB port...?
how can i send data through the USB port anyways?

thanks
hbe02 is offline   Reply With Quote
Old Jan 9th, 2007, 12:10 PM   #2
lectricpharaoh
Caffeinated Neural Net
 
lectricpharaoh's Avatar
 
Join Date: Jun 2005
Location: Wet west coast of Canada
Posts: 1,126
Rep Power: 5 lectricpharaoh will become famous soon enough
The names like COM3, LPT1, etc are derived in large part from the old DOS days. Back then, they usually (but not always) corresponded to fixed physical ports. A given machine would usually have one or two serial ports (generally COM1 and COM2), but could have more (up to four was possible without specialized hardware, but you still had to change jumpers and stuff, because COM1 and COM3 shared the same IRQ, as did COM2 and COM4).

For most modern machines, this stuff is all plug-and-play. You plug in a device, and the OS will detect it, and (attempt to) allocate the necessary resources. For most I/O devices, this involves mapping it to one or more I/O addresses, and sometimes giving it an IRQ. For USB devices, I expect that all devices on the same USB root hub share the same resources; the hardware and software multiplexes the communication through the use of control information in the data stream. That said, it's possible to get USB-to-serial and USB-to-parallel adapters. The OS and/or driver for the device will set up the adapter as a logical port that you can configure via the control panel or included software, and once this is done, you should have no trouble using the port in .NET.

[edit] It could also be that it's detecting your modem as a serial port, since it's a serial device. Check your modem in the control panel (most laptops still include one; I know mine does, and I bought it about 4 months ago) and see what port it's configured to use. [/edit]
__________________
And once again, Probability proves itself willing to sneak into a back alley and service Drama as would a copper-piece harlot.
- Vaarsuvius, Order of the Stick
lectricpharaoh is offline   Reply With Quote
Old Jan 10th, 2007, 7:25 PM   #3
hbe02
Hobbyist Programmer
 
hbe02's Avatar
 
Join Date: Mar 2006
Location: Lebanon
Posts: 148
Rep Power: 3 hbe02 is on a distinguished road
Very professionally said lectricpharaoh, thank you very much for clarifying this.
You were correct about my modem port being assigned to COM3. i can even change it to COM1,2.. and i have verified this using the piece of code in my first post.
I just ordered a USB to serial converter, should arrive in a few days. I will install its driver, which handles the communication and assigns it to a COM port.. after that i will be able to access it by using th eCOM port name assigned to it (being COM1,2,3,4)..
thanks..
hbe02 is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Data logging problem from the serial port jerryleo Perl 0 Jan 10th, 2006 8:47 AM
VB O5 Program Running Problem..Think its .net framework Silent Visual Basic .NET 3 Dec 15th, 2005 5:43 AM
Serial ports Benoit C 0 Sep 12th, 2005 5:41 PM
Goal of .Net Framework or Mono pr0gm3r Other Programming Languages 5 Sep 9th, 2005 4:28 PM
C programing control of the Serial Port. Light C++ 5 Feb 24th, 2005 3:14 PM




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 8:05 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC