summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsumeet142018-06-29 19:07:39 +0530
committersumeet142018-06-29 19:07:39 +0530
commit7273bd89b307f48f1455b010bb68a2ef95a45776 (patch)
tree65389a4fc3e2db7735e2d24132c5dd5db3985d60
parente100b91a6533f1eaceda2afc3162ec393f4e5475 (diff)
downloadOpenModelicaEmbedded-1-7273bd89b307f48f1455b010bb68a2ef95a45776.tar.gz
OpenModelicaEmbedded-1-7273bd89b307f48f1455b010bb68a2ef95a45776.tar.bz2
OpenModelicaEmbedded-1-7273bd89b307f48f1455b010bb68a2ef95a45776.zip
Suppot for Windows OS
-rw-r--r--Resources/Library/win64/modelPlugFirmata.dllbin0 -> 283217 bytes
-rw-r--r--Source/modelPlugFirmata.dllbin0 -> 283217 bytes
-rw-r--r--Source/modelPlugFirmata.obin0 -> 101932 bytes
-rwxr-xr-xSource/serial.cpp22
-rwxr-xr-xSource/serial.h4
-rw-r--r--Source/serial.obin0 -> 138622 bytes
-rw-r--r--modelPlugFirmata.dllbin0 -> 283217 bytes
-rw-r--r--package.mo29
8 files changed, 28 insertions, 27 deletions
diff --git a/Resources/Library/win64/modelPlugFirmata.dll b/Resources/Library/win64/modelPlugFirmata.dll
new file mode 100644
index 0000000..dd74a83
--- /dev/null
+++ b/Resources/Library/win64/modelPlugFirmata.dll
Binary files differ
diff --git a/Source/modelPlugFirmata.dll b/Source/modelPlugFirmata.dll
new file mode 100644
index 0000000..dd74a83
--- /dev/null
+++ b/Source/modelPlugFirmata.dll
Binary files differ
diff --git a/Source/modelPlugFirmata.o b/Source/modelPlugFirmata.o
new file mode 100644
index 0000000..c60e177
--- /dev/null
+++ b/Source/modelPlugFirmata.o
Binary files differ
diff --git a/Source/serial.cpp b/Source/serial.cpp
index 67e9be3..74441fe 100755
--- a/Source/serial.cpp
+++ b/Source/serial.cpp
@@ -52,7 +52,7 @@
#include <IOKit/IOKitLib.h>
#include <IOKit/serial/IOSerialKeys.h>
#include <IOKit/IOBSD.h>
-#elif defined(WINDOWS)
+#elif defined(WIN32)
#include <windows.h>
#define win32_err(s) FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, NULL, \
GetLastError(), 0, (s), sizeof(s), NULL)
@@ -166,7 +166,7 @@ int Serial::Open(const string& name)
settings.c_iflag = IGNBRK | IGNPAR;
Set_baud(baud_rate);
tcflush(port_fd, TCIFLUSH);
-#elif defined(WINDOWS)
+#elif defined(WIN32)
COMMCONFIG cfg;
COMMTIMEOUTS timeouts;
int got_default_cfg=0, port_num;
@@ -292,7 +292,7 @@ void Serial::Close(void)
#if defined(LINUX) || defined(MACOSX)
tcsetattr(port_fd, TCSANOW, &settings_orig);
close(port_fd);
-#elif defined(WINDOWS)
+#elif defined(WIN32)
//SetCommConfig(port_handle, &port_cfg_orig, sizeof(COMMCONFIG));
CloseHandle(port_handle);
#endif
@@ -390,7 +390,7 @@ int Serial::Set_baud(int baud)
cfsetospeed(&settings, (speed_t)baud);
cfsetispeed(&settings, (speed_t)baud);
if (tcsetattr(port_fd, TCSANOW, &settings) < 0) return -1;
-#elif defined(WINDOWS)
+#elif defined(WIN32)
DWORD len = sizeof(COMMCONFIG);
port_cfg.dcb.BaudRate = baud;
SetCommConfig(port_handle, &port_cfg, len);
@@ -425,7 +425,7 @@ int Serial::Read(void *ptr, int count)
n = read(port_fd, ptr, count);
if (n < 0 && (errno == EAGAIN || errno == EINTR)) return 0;
return n;
-#elif defined(WINDOWS)
+#elif defined(WIN32)
// first, we'll find out how many bytes have been received
// and are currently waiting for us in the receive buffer.
// http://msdn.microsoft.com/en-us/library/ms885167.aspx
@@ -504,7 +504,7 @@ int Serial::Write(const void *ptr, int len)
}
}
return written;
-#elif defined(WINDOWS)
+#elif defined(WIN32)
DWORD num_written;
OVERLAPPED ov;
int r;
@@ -548,7 +548,7 @@ int Serial::Input_wait(int msec)
FD_ZERO(&rfds);
FD_SET(port_fd, &rfds);
return select(port_fd+1, &rfds, NULL, NULL, &tv);
-#elif defined(WINDOWS)
+#elif defined(WIN32)
// http://msdn2.microsoft.com/en-us/library/aa363479(VS.85).aspx
// http://msdn2.microsoft.com/en-us/library/aa363424(VS.85).aspx
// http://source.winehq.org/WineAPI/WaitCommEvent.html
@@ -602,7 +602,7 @@ void Serial::Input_discard(void)
#if defined(LINUX) || defined(MACOSX)
// does this really work properly (and is it thread safe) on Linux??
tcflush(port_fd, TCIFLUSH);
-#elif defined(WINDOWS)
+#elif defined(WIN32)
PurgeComm(port_handle, PURGE_RXCLEAR);
#endif
}
@@ -613,7 +613,7 @@ void Serial::Output_flush(void)
if (!port_is_open) return;
#if defined(LINUX) || defined(MACOSX)
tcdrain(port_fd);
-#elif defined(WINDOWS)
+#elif defined(WIN32)
FlushFileBuffers(port_handle);
#endif
}
@@ -639,7 +639,7 @@ int Serial::Set_control(int dtr, int rts)
bits &= ~TIOCM_RTS;
}
if (ioctl(port_fd, TIOCMSET, &bits) < 0) return -1;;
-#elif defined(WINDOWS)
+#elif defined(WIN32)
// http://msdn.microsoft.com/en-us/library/aa363254(VS.85).aspx
if (dtr == 1) {
if (!EscapeCommFunction(port_handle, SETDTR)) return -1;
@@ -848,7 +848,7 @@ vector<string> Serial::port_list()
&serialPortIterator) != KERN_SUCCESS) return list;
macos_ports(&serialPortIterator, list);
IOObjectRelease(serialPortIterator);
-#elif defined(WINDOWS)
+#elif defined(WIN32)
// http://msdn.microsoft.com/en-us/library/aa365461(VS.85).aspx
// page with 7 ways - not all of them work!
// http://www.naughter.com/enumser.html
diff --git a/Source/serial.h b/Source/serial.h
index e49b4a7..f254c9b 100755
--- a/Source/serial.h
+++ b/Source/serial.h
@@ -7,7 +7,7 @@
#include <termios.h>
#elif defined(MACOSX)
#include <termios.h>
-#elif defined(WINDOWS)
+#elif defined(WIN32)
#include <windows.h>
#endif
@@ -47,7 +47,7 @@ private:
int port_fd;
struct termios settings_orig;
struct termios settings;
-#elif defined(WINDOWS)
+#elif defined(WIN32)
HANDLE port_handle;
COMMCONFIG port_cfg_orig;
COMMCONFIG port_cfg;
diff --git a/Source/serial.o b/Source/serial.o
new file mode 100644
index 0000000..4dd1ba9
--- /dev/null
+++ b/Source/serial.o
Binary files differ
diff --git a/modelPlugFirmata.dll b/modelPlugFirmata.dll
new file mode 100644
index 0000000..dd74a83
--- /dev/null
+++ b/modelPlugFirmata.dll
Binary files differ
diff --git a/package.mo b/package.mo
index e04f7f1..dc13527 100644
--- a/package.mo
+++ b/package.mo
@@ -274,7 +274,7 @@ end customBoard;
model BlinkLed "Basic example of blinking an LED"
extends Modelica.Icons.Example;
- replaceable OpenModelicaEmbedded.Boards.Arduino arduino(Port = "/dev/ttyACM0", ShowPinCapabilities = true, UseDTR = false) annotation(Placement(visible = true, transformation(origin = {30, -10}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
+ replaceable OpenModelicaEmbedded.Boards.Arduino arduino(Port = "COM4", ShowPinCapabilities = true, UseDTR = false) annotation(Placement(visible = true, transformation(origin = {30, -10}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
OpenModelicaEmbedded.Pins.DigitalOutput digitalOutput(Pin = 9) annotation(Placement(visible = true, transformation(origin = {0, -10}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
Modelica_DeviceDrivers.Blocks.OperatingSystem.SynchronizeRealtime synchronizeRealtime1 annotation(
Placement(visible = true, transformation(origin = {35, 15}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
@@ -1159,11 +1159,11 @@ end ArduinoExamples;
Placement(visible = true, transformation(origin = {-3.55271e-15, 3.55271e-15}, extent = {{-20, -20}, {20, 20}}, rotation = 0)));
OpenModelicaEmbedded.Pins.DigitalOutput digitalOutput2(Pin = 30) annotation(
Placement(visible = true, transformation(origin = {-3.55271e-15, -60}, extent = {{-20, -20}, {20, 20}}, rotation = 0)));
- Modelica.Blocks.Sources.BooleanPulse booleanPulse1(period = 20, startTime = 5, width = 25) annotation(
+ Modelica.Blocks.Sources.BooleanPulse booleanPulse1(period = 2, startTime = 0, width = 50) annotation(
Placement(visible = true, transformation(origin = {-60, 3.55271e-15}, extent = {{-20, -20}, {20, 20}}, rotation = 0)));
- Modelica.Blocks.Sources.BooleanPulse booleanPulse2(period = 20, startTime = 5, width = 40) annotation(
+ Modelica.Blocks.Sources.BooleanPulse booleanPulse2(period = 2, startTime = 1, width = 50) annotation(
Placement(visible = true, transformation(origin = {-60, -60}, extent = {{-20, -20}, {20, 20}}, rotation = 0)));
- OpenModelicaEmbedded.Boards.customBoard customBoard1(BoardName = "Tiva C", Port = "/dev/ttyACM0") annotation(
+ OpenModelicaEmbedded.Boards.customBoard customBoard1(BoardName = "Tiva C", Port = "COM6") annotation(
Placement(visible = true, transformation(origin = {60, -20}, extent = {{-20, -20}, {20, 20}}, rotation = 0)));
equation
connect(digitalOutput1.pinConnector, customBoard1.boardConnector) annotation(
@@ -1644,7 +1644,7 @@ end ArduinoExamples;
input Integer adcResolution;
output Real value;
- external "C" value = readAnalogPin(pin, min, max, init, board, adcResolution) annotation(Include = "#include \"modelPlugFirmata.h\"", Library = "modelPlugFirmata", IncludeDirectory = "modelica://OpenModelicaEmbedded/Resources/Include", LibraryDirectory = "modelica://OpenModelicaEmbedded/Resources/Library");
+ external "C" value = readAnalogPin(pin, min, max, init, board, adcResolution) annotation(Library = "modelPlugFirmata", IncludeDirectory = "modelica://OpenModelicaEmbedded/Resources/Include");
end readAnalogPin;
@@ -1668,13 +1668,13 @@ end ArduinoExamples;
input Boolean UseDTR;
output FirmataBoardObject board;
- external "C" board = boardConstructor(port, showCapabilities, samplingMs, BaudRate, UseDTR) annotation(Include = "#include \"modelPlugFirmata.h\"", Library = "modelPlugFirmata", IncludeDirectory = "modelica://OpenModelicaEmbedded/Resources/Include", LibraryDirectory = "modelica://OpenModelicaEmbedded/Resources/Library");
+ external "C" board = boardConstructor(port, showCapabilities, samplingMs, BaudRate, UseDTR) annotation(Library = "modelPlugFirmata", IncludeDirectory = "modelica://OpenModelicaEmbedded/Resources/Include");
end constructor;
function destructor "Function to destroy the object"
input FirmataBoardObject board;
- external "C" boardDestructor(board) annotation(Include = "#include \"modelPlugFirmata.h\"", Library = "modelPlugFirmata", IncludeDirectory = "modelica://OpenModelicaEmbedded/Resources/Include", LibraryDirectory = "modelica://OpenModelicaEmbedded/Resources/Library");
+ external "C" boardDestructor(board) annotation(Library = "modelPlugFirmata", IncludeDirectory = "modelica://OpenModelicaEmbedded/Resources/Include");
end destructor;
end FirmataBoardObject;
@@ -1682,7 +1682,7 @@ end ArduinoExamples;
input FirmataBoardObject board;
output Integer id;
- external "C" id = getBoardId(board) annotation(Include = "#include \"modelPlugFirmata.h\"", Library = "modelPlugFirmata", IncludeDirectory = "modelica://OpenModelicaEmbedded/Resources/Include", LibraryDirectory = "modelica://OpenModelicaEmbedded/Resources/Library");
+ external "C" id = getBoardId(board) annotation(Library = "modelPlugFirmata", IncludeDirectory = "modelica://OpenModelicaEmbedded/Resources/Include");
end getBoardId;
function readDigitalPin
@@ -1691,7 +1691,7 @@ end ArduinoExamples;
input Integer board;
output Boolean value;
- external "C" value = readDigitalPin(pin, init, board) annotation(Include = "#include \"modelPlugFirmata.h\"", Library = "modelPlugFirmata", IncludeDirectory = "modelica://OpenModelicaEmbedded/Resources/Include", LibraryDirectory = "modelica://OpenModelicaEmbedded/Resources/Library");
+ external "C" value = readDigitalPin(pin, init, board) annotation(Library = "modelPlugFirmata", IncludeDirectory = "modelica://OpenModelicaEmbedded/Resources/Include");
end readDigitalPin;
function writeAnalogPin
@@ -1699,7 +1699,7 @@ end ArduinoExamples;
input Integer board;
input Real value;
- external "C" writeAnalogPin(pin, board, value) annotation(Include = "#include \"modelPlugFirmata.h\"", Library = "modelPlugFirmata", IncludeDirectory = "modelica://OpenModelicaEmbedded/Resources/Include", LibraryDirectory = "modelica://OpenModelicaEmbedded/Resources/Library");
+ external "C" writeAnalogPin(pin, board, value) annotation(Library = "modelPlugFirmata", IncludeDirectory = "modelica://OpenModelicaEmbedded/Resources/Include");
end writeAnalogPin;
function writeDigitalPin
@@ -1707,13 +1707,13 @@ end ArduinoExamples;
input Integer board;
input Boolean value;
- external "C" writeDigitalPin(pin, board, value) annotation(Include = "#include \"modelPlugFirmata.h\"", Library = "modelPlugFirmata", IncludeDirectory = "modelica://OpenModelicaEmbedded/Resources/Include", LibraryDirectory = "modelica://OpenModelicaEmbedded/Resources/Library");
+ external "C" writeDigitalPin(pin, board, value) annotation(Library = "modelPlugFirmata", IncludeDirectory = "modelica://OpenModelicaEmbedded/Resources/Include");
end writeDigitalPin;
function updateBoard
input Integer board;
- external "C" updateBoard(board) annotation(Include = "#include \"modelPlugFirmata.h\"", Library = "modelPlugFirmata", IncludeDirectory = "modelica://OpenModelicaEmbedded/Resources/Include", LibraryDirectory = "modelica://OpenModelicaEmbedded/Resources/Library");
+ external "C" updateBoard(board) annotation(Library = "modelPlugFirmata", IncludeDirectory = "modelica://OpenModelicaEmbedded/Resources/Include");
end updateBoard;
function writeServoPin
@@ -1723,12 +1723,13 @@ end ArduinoExamples;
input Integer MinPulse;
input Integer MaxPulse;
- external "C" writeServoPin(pin, board, value, MinPulse, MaxPulse) annotation(Include = "#include \"modelPlugFirmata.h\"", Library = "modelPlugFirmata", IncludeDirectory = "modelica://OpenModelicaEmbedded/Resources/Include", LibraryDirectory = "modelica://OpenModelicaEmbedded/Resources/Library");
+ external "C" writeServoPin(pin, board, value, MinPulse, MaxPulse) annotation(Library = "modelPlugFirmata", IncludeDirectory = "modelica://OpenModelicaEmbedded/Resources/Include");
end writeServoPin;
annotation(Icon(coordinateSystem(extent = {{-100, -100}, {100, 100}}, preserveAspectRatio = true, initialScale = 0.1, grid = {10, 10}), graphics = {Text(visible = true, origin = {11.425, 9.596}, extent = {{-101.424, -59.596}, {78.57599999999999, 40.404}}, textString = "EF")}), Documentation(info = "", revisions = ""), Diagram(coordinateSystem(extent = {{-148.5, 105}, {148.5, -105}}, preserveAspectRatio = true, initialScale = 0.1, grid = {10, 10})), Icon(coordinateSystem(extent = {{-100, -100}, {100, 100}}), graphics = {Rectangle(visible = true, fillColor = {209, 209, 209}, fillPattern = FillPattern.Solid, extent = {{-100, -100}, {75, 75}}), Polygon(visible = true, fillColor = {236, 236, 236}, fillPattern = FillPattern.Solid, points = {{-100, 75}, {-75, 100}, {100, 100}, {75, 75}}), Polygon(visible = true, fillColor = {177, 177, 177}, fillPattern = FillPattern.Solid, points = {{75, -100}, {75, 75}, {100, 100}, {100, -75}}), Text(visible = true, extent = {{-95.95, -91.88}, {63.97, 71.52}}, textString = "C")}));
end ExternalFunctions;
+
package Types "Type and unit definitions"
extends Modelica.Icons.TypesPackage;
type ServoUnit = enumeration(None, Degrees, Radians);
@@ -1854,4 +1855,4 @@ end ArduinoExamples;
<p>&nbsp;</p>
<p>&nbsp;</p></html>", revisions = ""), version = "1.2", Icon(coordinateSystem( initialScale = 0.1, grid = {5, 5}), graphics = {Rectangle(fillColor = {0, 170, 255}, pattern = LinePattern.None, fillPattern = FillPattern.Solid, extent = {{-100, -100}, {100, 100}}, radius = 25), Text(origin = {-47.5, 55}, extent = {{-42.5, 15}, {137.5, -80}}, textString = "OpenModelica", textStyle = {TextStyle.Bold}), Text(origin = {2.5, -15}, extent = {{-77.5, 15}, {77.5, -15}}, textString = "Embedded", textStyle = {TextStyle.Bold})}), Diagram(coordinateSystem(extent = {{-148.5, -105}, {148.5, 105}}, preserveAspectRatio = true, initialScale = 0.1, grid = {5, 5})),
uses(Modelica_DeviceDrivers(version = "1.5.0"), Modelica(version = "3.2.2")));
-end OpenModelicaEmbedded; \ No newline at end of file
+end OpenModelicaEmbedded;