Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .vscode/arduino.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@
"port": "COM4",
"configuration": "cpu=atmega2560",
"board": "arduino:avr:mega",
"sketch": "Arduino-Test-Code\\Arduino-Test-Code.ino"
"sketch": "Arduino-Test-Code\\Arduino-Test-Code.ino",
"programmer": "arduinoisporg"
}
28 changes: 28 additions & 0 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"tasks": [
{
"type": "cppbuild",
"label": "C/C++: g++.exe build active file",
"command": "C:\\msys64\\ucrt64\\bin\\g++.exe",
"args": [
"-fdiagnostics-color=always",
"-g",
"${file}",
"-o",
"${fileDirname}\\${fileBasenameNoExtension}.exe"
],
"options": {
"cwd": "${fileDirname}"
},
"problemMatcher": [
"$gcc"
],
"group": {
"kind": "build",
"isDefault": true
},
"detail": "Task generated by Debugger."
}
],
"version": "2.0.0"
}
2 changes: 2 additions & 0 deletions Arduino-Test-Code/Arduino-Test-Code.ino
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ void loop() {
Serial.write(Serial.read()); // echo received data
}
}
Serial.println("Hello World");
delay(100);



Expand Down
76 changes: 76 additions & 0 deletions mainCode/SerialDEV.pde
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
public void searchForPortsDEV() {
if (connectedToCOM == false) {
commPorts = SerialPort.getCommPorts(); // get available comm ports
systemPrintln("Found " + commPorts.length + " serial ports", "debug"); // print number of ports

// iterate through port list and print detailed info
for (SerialPort commPort : commPorts) {
systemPrint("\n" + "System port name " + commPort.getSystemPortName() + ", ", "debug");
systemPrint("Descriptive port name " + commPort.getDescriptivePortName() + ", ", "debug");
systemPrint("Is Port opened ? " + commPort.isOpen() + "\n", "debug");
}

availableCOMs = new String[commPorts.length];
// iterate through port list and add them to availableCOMs
for (int i = 0; i < commPorts.length; i ++) {
availableCOMs[i] = commPorts[i].getSystemPortName();
}

systemPrintln(java.util.Arrays.toString(availableCOMs), "debug");

if (availableCOMs.length > 0) {
portsFound = true;
selectedPort = availableCOMs[0];
if (advancedOptions == true) {
buttonConnect.setText("Disconnected-click to connect " + selectedPort + "@" + selectedBaudRate + "," + selectedParity + "," + selectedDataBits + "," + selectedStopBits);
} else {
buttonConnect.setText("Disconnected-click to connect " + selectedPort + "@" + selectedBaudRate);
}
} else {
portsFound = false;
buttonConnect.setText("No serial ports found");
}
} else if (connectedToCOM) {
commPorts = SerialPort.getCommPorts(); // get available comm ports
availableCOMs = new String[commPorts.length]; // resize COM list to match commPorts.length

// iterate through port list and add them to availableCOMs
for (int i = 0; i < commPorts.length; i ++) {
availableCOMs[i] = commPorts[i].getSystemPortName();
}

if (availableCOMs[0].equals(selectedPort) == true || availableCOMs[comboBoxPortSelectedIndex].equals(selectedPort) == true) {
systemPrintln("connected port found" + availableCOMs[0], "debug");
} else {
}
}
}



// if (connectedToCOM == false) {
// availableCOMs = Serial.list();
// if (availableCOMs.length > 0) {
// portsFound = true;
// selectedPort = availableCOMs[0];
// if (advancedOptions == true) {
// buttonConnect.setText("Disconnected-click to connect " + selectedPort + "@" + selectedBaudRate + "," + selectedParity + "," + selectedDataBits + "," + selectedStopBits);
// } else {
// buttonConnect.setText("Disconnected-click to connect " + selectedPort + "@" + selectedBaudRate);
// }
// } else {
// portsFound = false;
// buttonConnect.setText("No serial ports found");
// }
// } else if (connectedToCOM) {
// availableCOMs = Serial.list();
// if (availableCOMs[0].equals(selectedPort) == true || availableCOMs[comboBoxPortSelectedIndex].equals(selectedPort) == true) {
// systemPrintln("connected port found" + availableCOMs[0], "debug");
// } else {
// }
// }





Binary file added mainCode/code/jSerialComm-2.11.4.jar
Binary file not shown.
4 changes: 3 additions & 1 deletion mainCode/libs.pde
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,6 @@ import java.io.File; //import file library
import java.io.FileWriter; //import file writer library
import java.util.Collections; //import collections library
import java.util.Scanner; //import scanner library
import java.util.Arrays; //import arrays library
import java.util.Arrays; //import arrays library

import com.fazecast.jSerialComm.*;
26 changes: 21 additions & 5 deletions mainCode/mainCode.pde
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ BufferedImage convertToBufferedImage(PImage imgToConvert) {
systemPrintln("convertToBufferedImage complete @ " + millis(), "debug");
return convertedImg;
}
// print to system console
// print newline to system console
public void systemPrintln(String msg, String type) {
try {
if (showDebugStatements == true) {
Expand All @@ -142,6 +142,22 @@ public void systemPrintln(String msg, String type) {
catch (Exception error) {
}
}
// print to system console
public void systemPrint(String msg, String type) {
try {
if (showDebugStatements == true) {
if (type.equals("debug")) {
System.out.print(msg);
} else if (type.equals("error")) {
System.err.print(msg);
}
} else {
//do nothing
}
}
catch (Exception error) {
}
}

// set terminal text fonts
public void setFont(String fontName, float fontSize) {
Expand Down Expand Up @@ -287,9 +303,6 @@ public void setupMain() {
while (mainUiInit == false) {
delay(1);
}
setFont(selectedFont, selectedFontSize);
searchForPorts(); // search for available serial ports
initSearch(); // initialize textAreaMain searching
//set startup message length based on selected font size
if (selectedFontSize == 12) {
textAreaMainMsg("", " -------------------------------------" + versionInfo + "-------------------------------------", "");
Expand All @@ -301,13 +314,16 @@ public void setupMain() {
textAreaMainMsg("", " -------------------" + versionInfo + "--------------------", "");
}
textAreaMainMsg("\n", "Enter -h for help", ""); //print help message
setFont(selectedFont, selectedFontSize);
searchForPortsDEV();
//searchForPorts(); // search for available serial ports
initSearch(); // initialize textAreaMain searching
systemPrintln("Startup complete" + " @ " + millis(), "debug");
}

// Processing setup function
public void setup() {
setupMain(); // software setup function

// enter code here
}

Expand Down
2 changes: 1 addition & 1 deletion mainCode/processSerial.pde
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
//search for available serial ports
public void searchForPorts() {

if (connectedToCOM == false) {
if (connectedToCOM == false) {//
availableCOMs = Serial.list();
if (availableCOMs.length > 0) {
portsFound = true;
Expand Down
8 changes: 6 additions & 2 deletions mainCode/settingsWindowUI.pde
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,12 @@ void drawPortConfig() {
buttonRefreshCOMs.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent actionEvent) {
if (connectedToCOM == false) {
availableCOMs = processing.serial.Serial.list(); //get available serial ports
comboBoxPort.setModel(new DefaultComboBoxModel(availableCOMs));
commPorts = SerialPort.getCommPorts();
availableCOMs = new String[commPorts.length];
// iterate through port list and add them to availableCOMs
for (int i = 0; i < commPorts.length; i ++) {
availableCOMs[i] = commPorts[i].getSystemPortName();
} comboBoxPort.setModel(new DefaultComboBoxModel(availableCOMs));
systemPrintln("Available COMs:" + java.util.Arrays.toString(availableCOMs), "debug");
systemPrintln("buttonRefreshCOMs clicked @ " + millis(), "debug");
} else {
Expand Down
1 change: 0 additions & 1 deletion mainCode/sketch.properties

This file was deleted.

5 changes: 3 additions & 2 deletions mainCode/variables.pde
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ int prevCommandsIndex = 0; // count of up key presses for previous comma

char selectedParity = 'N'; //serial port parity 'N' for none, 'E' for even, 'O' for odd, 'M' for mark, 'S' for space ('N' is the default)

boolean showDebugStatements = false; // if true show debug statements in console
boolean showDebugStatements = true; // if true show debug statements in console
boolean connectToCOM = false; // if connecting to com port
boolean connectedToCOM = false; // if connected to com port
boolean loggingData = false ; // if logging succeeded
Expand Down Expand Up @@ -56,7 +56,6 @@ String stopBitList[] = {"1.0", "1.5", "2.0"};
String selectedParityString = parityList[0]; // String value of selected parity for display purposes
String selectedDataBitsString = dataBitList[3]; // String value of selected data bits for display purposes
String selectedStopBitsString = stopBitList[0]; // String value of selected stop bits for display purposes
String serialPortList[];
String enteredCommand = ""; // command entered in textFieldMain updates on enter press
String validCommands[] = { // list of valid commands
"-h", // help
Expand Down Expand Up @@ -110,6 +109,8 @@ int intBaudRate = int(selectedBaudRate); // integer value of selected
processing.serial.Serial COMPort = null; // create object of Serial class
Table preferenceTable; // preferences table

SerialPort[] commPorts; // list of available serial ports


//Controls for main window
javax.swing.JFrame frameMainWindow; //create instance of JFrame
Expand Down