Some fun news first, We now have a logo for the "Company" (as this is a mock project, its a mock company). We are Called Alpha Vending Solutions
I have just managed to get working the Maintenance mode Software using visual c#. The fix to get the serial port object to work was annoyingly simple once I found it.
The main use of this software will be to test functionality of the system, Send servo commands, read sensors and such. As we still are not fully sure on what software we will need, it has been made as a MDI (Multiple Document Interface) to allow more forms and controls to be added as needed.
The fix i found for getting the serial ports to work over multiple forms was to pass the Serial Port which has been opened in the main form to the other forms as an argument, see bellow
On the Form to be opened
using System.IO.Ports; SerialPort serial = new SerialPort(); public Servo(SerialPort port) { InitializeComponent(); serial = port; }
On the Main Form
using System.IO.Ports; SerialPort sp = new SerialPort(); private void servoToolStripMenuItem_Click(object sender, EventArgs e) { Servo SVR = new Servo(sp) { MdiParent = this }; SVR.Show(); }
So in the main form 'sp' is opened with the required com port, using the menu. Then it is passed to the other forms when they are opened, and set to another serial port object. So far this solution is working for me and i hope to keep it that way.
The only issue I can see being with this, is that it requires me to use the readline() and Writeline() method in every form and have the required exception handling every time. although after the trouble I had trying to get this to work in the first place, i really don't mind having the extra work. I could also see an error happening if you open the form before opening the Com port.
This afternoon we will be interfacing the MBed with the software to read the colour sensor and display the results, and i will be sitting down with the mechanical design team to work out the state machine i will need to implement on the FPGA. Ill try and post about them as well
Top Comments