Thanks for the replies - Im going to make the changes you request, well to the naming convention at least, as for the serial port, I will only ever have 1 serial port. I am communicating with an Arduino and it will control the switch to open/shut the observatory roof.
Figured it out - I found out that what I was actually doing was creating a second timer object which was populating a list box, this meant it was populating twice 1 for each timer and not creating a 2nd port!
I have a class that creates and opens a serial port:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO.Ports;
namespace ObservatoryControl
{
public static class ObservatoryPortProvider
{
private...
Found another article that was easier to use that background worker:
if (ListBoxState.InvokeRequired)
{
ListBoxState.Invoke(new MethodInvoker(delegate { ListBoxState.Items.Add(roof.serialdata); }));
}
Following from this afternoons question..... I have a class, roof, which has a public string, serialdata. Im setting the value of this by a timer which runs every 2 seconds to query the serial port. I then have a list box Im trying to populate with this data, by doing the same - creating a...
Hi,
Pretty much new to programming and defiantly new to OOP, so go easy! Im writing a tiny Windows Form app that will be used to open and close my observatory roof. I have created a seperate class for my observatory object but I will be communicating with the actual roof through the...
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.