summaryrefslogtreecommitdiff
path: root/ArduinoCode/IPCArdNew
diff options
context:
space:
mode:
authorSiddharth112352019-09-03 18:09:16 +0530
committerSiddharth112352019-09-03 18:09:16 +0530
commitb4b6aa36e3486a3544acc52419149b5671f841e9 (patch)
tree66c1783158f23e6d21c77324156fc57e18d4ac67 /ArduinoCode/IPCArdNew
parentf5266f634f4fb4fd39933a83551a01cf446256b8 (diff)
downloadOpenModelica_HIL-b4b6aa36e3486a3544acc52419149b5671f841e9.tar.gz
OpenModelica_HIL-b4b6aa36e3486a3544acc52419149b5671f841e9.tar.bz2
OpenModelica_HIL-b4b6aa36e3486a3544acc52419149b5671f841e9.zip
Pushing entire Modelica HIL Tasks repoHEADmaster
Diffstat (limited to 'ArduinoCode/IPCArdNew')
-rwxr-xr-xArduinoCode/IPCArdNew/IPCArdNew.ino27
1 files changed, 27 insertions, 0 deletions
diff --git a/ArduinoCode/IPCArdNew/IPCArdNew.ino b/ArduinoCode/IPCArdNew/IPCArdNew.ino
new file mode 100755
index 0000000..3f9ae24
--- /dev/null
+++ b/ArduinoCode/IPCArdNew/IPCArdNew.ino
@@ -0,0 +1,27 @@
+void setup()
+{
+ Serial.begin(115200); //serial begin
+}
+
+void loop()
+{
+ String readStr = ""; //some variables
+ String readVal = "";
+ double inVal, outVal;
+
+ if (Serial.available()){ //when serial data comes from modelica
+ while(Serial.available()){
+ char readChar = (char)Serial.read();
+ readStr+=readChar;
+ if(readChar == '\n') break;
+ } //read the data and store in a string
+ for (int i = 1; i < (readStr.length()-1); i++)
+ {
+ readVal += readStr[i];
+ }
+ inVal = readVal.toDouble(); //extract value
+ outVal = inVal/2;
+ Serial.print("1," + String(outVal) + "\n"); //send data in same format i.e. ending with \n character
+ delay(1);
+ }
+}