Main Site Documentation

Difference Between SerialPort() class and Serial() class NETMF


#1

Can someone please elaborate on the difference between these two classes and how to use them properly? I see SerialPort() contains all the open, close, and dispose methods whereas Serial() has the fields for COM1,COM2, ect…do both classes get used when initiating and moving data across a serial connection? I can’t find any examples in the documentation or a solid one on the forums.

Should I even use the SerialPort() class or should I use a custom class from codeshare? The link to the expanded class on codeshare was broken.


#2

I’m using System.IO.Ports.SerialPort it works very well.

Example code is here:

http://developer.wildernesslabs.co/Netduino/Input_Output/Digital/UART/


#3

That is fantastic thank you so much! Exactly the type of guide I need.


#4

If I am setting up a USB port on the G30 using an FT232 USB to Serial chip, is COM1 preferred over COM2? What is the main difference, handshake lines? My knowledge of USB and serial communication is still a work in progress.

I assume on top of the COM pins being made into a USB port, I would separately want to utilize the USBD+ and USBD- pins for a micro USB debug and code deployment port, correct?


#5

Can’t answer the first part as I haven’t got that far and messed with the FT232, but yes, USB+/- for a debug port

I use that to deploy firmware and software to the device. You can use COM1 DTE as well (that’s what the mode button is for) to flash with, but I don’t have any PC’s sitting around that I can hook a DB9 serial port in to so I just used USB. There is the option of using either, though. Besides USB for debugging and code deployment straight from Visual Studio is an awesome thing.


#6

Thank you my friend, I hope your design is going well. You are slightly ahead of me protoyping (this is my first embedded design project as well). I am kicking ass though should be cranking out the first (and hopefully only) PCB design in a week or two.


#7

@Gus_Issa Why does COM1 not have hand shake lines on the G30 but COM2 does? Trying to decide which one to put an FT232 on and which to put a home made GPIB controller on.


#8

Not sure how to answer this question. Use the one you need. If you need handshaking then use the one that has handshaking. Is this what your are asking?


#9

Well I was told by Justin to use SPI1 over SPI2 on the G30 (guessing because it has some clock frequency sync issues) and am wondering if one of the COM ports works better than the other in the same way that SPI1 is preferred over SPI2.


#10

What’s wrong with SPI2?? That’s used for display and ethernet on the G30 dev board.

I’m just curious; I just finished a PCB design that’s going to use it heavily.

As far as COM ports it depends on what you are going to work with. A lot of devices will require handshaking. Some stuff won’t. Check your device(s) that you plan on using if there’s questions. If it’s a PC, you’ll need handshaking. If it’s a thermostat… maybe not. :slight_smile:


#11

@Justin Can you elaborate on your previous advising to use SPI1 on the G30 when I was setting up my L6470? You said just to trust you and of course I did I never got a solid explanation if I recall.

My only input is I had one hell of a time getting the clock frequency right…it would only work at 1000 kHz otherwise the registries on the L6470 would not set. That may have been specific to that interface, I can’t say for certain since that was my first time working with SPI but I had no trouble with other any interface types like parallel.


#12

How do I find System.IO.Ports.SerialPort? Having trouble finding the correct reference to add all I see is SPOT.Hardware.SerialPort which does not have the needed definitions.


#13

Nevermind I got it…the correct name is System.IO.Ports the SerialPort part should not be there.