ArduinIO thread - A generic(ish) arduino IO module for DomotiGa to make it easier to integrate arduino's

Added by thechad almost 5 years ago

Hi Guys,
I have created arduino that runs a set of 16 relays, 8 (opto-isolated) digital inputs, analogue inputs and remote devices over RFM12B (same radio as used by jeelabs).

It's running a simple command protocol using cmdMessenger.[[http://playground.arduino.cc/Code/CmdMessenger]]

I've compled the first alpha of the module (and associated table/form etc) changes and all is looking ok so far. (I used JeeLabs and the wiki as a guide).

It uses the address field for the device to first match the response to a device and then "Parse" the response into the 4 value fields (CEIB devices does a similar thing...hence my other post re. making Devices.FindRegExp more generic.

So let's say, you have an arduino that controls 8 relays over a serial port and the arduino sends the state of the 8 relays when they change (for example) R1=0 or R1=1 or R2=0 or R2 = 1 etc You would create a device with an address field of "|R1=|R2=|R3=|R4=|"
I am using the address field and the "DevicesFindRegExp" function to find and then update the appropriate device value for the device (ie R1 would update value1 in the device that has |R1| in the address field.

To turn a relay off, run a Device action (in the case of cmdMessenget implementation, the command "10,1;" (ie. setting the device value1 in the action to "10,1;" ) will turn the relay on, "11,1;" will turn relay 1 off, 12,1; will toggle relay 1 and 13,1,1000; will pulse relay 1 for 1 second, 14,1; returns the state etc. Digital Inputs are interupt driven and can be set to trigger on rising/change or falling levels, as well as count pulses, inverted etc etc Settings are saved on the arduino eeprom.

Relatively simple and perfect for my use....but, except for the outgoing command (which can be any string as it no longer updates value1 - this is only updated by the arduino input) it is not very generic.

I started thinking how could I make this more generic and am starting to play with the idea of
1) a regex field on the interface form that describes to the module how to parse the incoming data to determine the "key" to lookup the device address fields
2) a field on the interface form for a delimiter charater for where there is more than one value field.

These fields would go in the settings_arduinio table which I have complete control over given this is a new interface.

In my case, the data comes in from the Arduino in the following format.
<identifier>=<value>;/r/n
ie. R16=1;/r/n <- Relay 16 is on
D8=1;/r/n <- Digital input 8 is on
DC1=1242;/r/n _ <- Digital Counter 1 has counted 1242 pulses_
_Note: to keep it simple, let's assume all data is terminated by a carridge return and a linefeed (/r/n)

So, (for example) a regex of ^[^=]* would give:
R16
D8
DC1

And so this could be used to locate the appropriate device/value and update it.

Using a different regex, it could also handle other formats as long as they follow this standard...
eg. temp:100
speed 10.232134
OK 12 567.54 <where 12 is the device identifier
etc

To handle multiple values on the same line (max. 4 of course and all must belong to the same device), I plan to include a "field separator" in the interface form. This will default to space.
If I see more than one value field in the input line, then we must be storing all values in the one device (ie. someuniquedeviceID,value1, value2, value3,value4)

As an example of the flexability this gives, I could read in a Jeelabs sensor for example with a REGEX which selected only the second word and look this up as the devicei address and the field delimiter would be space.
ie. OK 34 12.2323 84.2 23 44 NO 3.25
where
OK is ignored by the REGEX
34 is returned by the regex as the device address which is looked up in the address field to find a match of |34|
12.2323 is stored in value 1 (ie. temp)
84.2 is stored in value 2 (humidity)
23 44 is stored in value 3 (light)
NO is stored in value 4 (motion)
3.25 is stored in battery voltage (5th parameter if present will always be assumed to be avoltage - verify it's a number etc of course)
I'm not 100% on the jeelabs format but you get the idea!)

This all looks quite simple, but before I hack it up, I know you guys are looking at stuff like this all the time so i'd really appreciate your thoughts on...
1) Has this all been done before?
2) Any pointers/holes in the above?
3) Any regex experts out there! That stuff messes with my mind!!!!!
4) anything else you might have to share (ie. I note the current structure only allows for one interface...ie, one arduino).

At the very least, I'll make it work for my board and put the code somewhere so anyone else who want to add a custom arduino it has an example.

Cheers.


Replies (37)

RE: ArduinIO thread - A generic(ish) arduino IO module for DomotiGa to make it easier to integrate arduino's - Added by janno almost 5 years ago

Interesting project, maybe open source it :-). I had a challenge a little bit like this and just used a shell script as an intermediate solution to parse the the data to the right format / for the right device.

RE: ArduinIO thread - A generic(ish) arduino IO module for DomotiGa to make it easier to integrate arduino's - Added by thechad almost 5 years ago

Thanks for the reply janno

a scipt is a reasonable way to go...I was using a twisted python script (to allow multithreading and broadcast to multiple connected devices)...but I wanted an integrated and simple solution...so I thought I would have a go at writing an interface for the arduino and make it as generic as i could.

I have completed the first beta and all seems to be working as hoped.

Here are some pics of it in operation...(note just look at the arduinio devices..as the others are just dummy's).


The below is a debug log...(not that it'll mean much to others without the code to look at...but it might) and it shows the basic logic flow.
Note this was triggered from the following XMLRPC call...

curl -H 'Content-Type: text/xml' -d '<methodCall><methodName>device.setdevice</methodName><params><param><value><string>ArduinIO - Relays 1-4</string></value></param><param><value><string>12,2;</string></value></param></params></methodCall>' 127.0.0.1:9009


2013/08/25 21:40:16 [XMLRPC] Got a RemoteCall for method 'device.setdevice'
2013/08/25 21:40:16 [XMLRPC] Param[0] = 'ArduinIO - Relays 1-4'
2013/08/25 21:40:16 [XMLRPC] Param[1] = '12,2;'
2013/08/25 21:40:16 [XMLRPC] in DeviceSetDevice
2013/08/25 21:40:16 [XMLRPC] Param[0] = 'ArduinIO - Relays 1-4'
2013/08/25 21:40:16 [XMLRPC] Param[1] = '12,2;'
2013/08/25 21:40:16 [XMLRPC] in DeviceSetDevice Try Devices.SetDevice(sParams[0], sParams[1])
2013/08/25 21:40:16 [Devices] Interface for device with name 'ArduinIO - Relays 1-4' is '48'
2013/08/25 21:40:16 [Devices] Address for device with name 'ArduinIO - Relays 1-4' is '|R1=|R2=|R3=|R4=|'
2013/08/25 21:40:16 [Devices] Device with address '|R1=|R2=|R3=|R4=|' is 'ArduinIO - Relays 1-4'
2013/08/25 21:40:16 [Devices] ArduinIO Interface: |R1=|R2=|R3=|R4=| 12,2;
2013/08/25 21:40:16 [Devices] Interface with name 'ArduinIO Interface' has id '48'
2013/08/25 21:40:16 [Devices] Device with address '|R1=|R2=|R3=|R4=|' is 'ArduinIO - Relays 1-4'
2013/08/25 21:40:16 [ArduinIO] SendCommand (sAddress='|R1=|R2=|R3=|R4=|', sCmd = '12,2;')
2013/08/25 21:40:16 [ArduinIO] Raw DataR2=1
2013/08/25 21:40:16 [ArduinIO] Processing LineR2=1
2013/08/25 21:40:16 [ArduinIO] ------------ in ParseLine ----------------------
2013/08/25 21:40:16 [ArduinIO] Data from serial Port (R2=1) with regex (^.*?[=]) applied gives AddressToChange of : R2=
2013/08/25 21:40:16 [Devices] Interface with name 'ArduinIO Interface' has id '48'
2013/08/25 21:40:16 [Devices] Device with address 'R2=' is 'ArduinIO - Relays 1-4'
2013/08/25 21:40:16 [ArduinIO] Updating :R2= to 1
2013/08/25 21:40:16 [ArduinIO] iDeviceId:46sAddress:|R1=|R2=|R3=|R4=|
2013/08/25 21:40:16 [Devices] ValueUpdate() called for device with id '46' and name 'ArduinIO - Relays 1-4'
2013/08/25 21:40:16 [Devices] Device change triggered for device with id '46' and value2 '1'
2013/08/25 21:40:16 [Devices] Creating log record for device with id '46' and 'value2' = '1'
2013/08/25 21:40:16 [ArduinIO] Update Value2:1

I'd be really keen to hear any thoughts on how this is shaping up so far.

One thing I will definitely do is include a test and result field in the "Interface" form so you can try out the regex on the form and verify it gives the extected result.

EDIT: Just added the test code to the interface form...nothing flas, but it seems to work ok.

and this one using a differnt regex and delimiter.

RE: ArduinIO thread - A generic(ish) arduino IO module for DomotiGa to make it easier to integrate arduino's - Added by rdnzl almost 5 years ago

Nice work.
I would be happy to give it a go in including it in the svn repository.
When you think you are ready you can send me the code and sql updates, and maybe a little info. ;-)
Do I understand correctly that this can also replace the jeelabs code/interface?
If so maybe we rename and change that one.

Rdnzl.

RE: ArduinIO thread - A generic(ish) arduino IO module for DomotiGa to make it easier to integrate arduino's - Added by thechad almost 5 years ago

Hi,
it's still some weeks away from a releasable version...as I do want to include a few more things, do a load more testing (incl. auto creation) clean up and document the code, (do a wiki page?) I will not have any free time this week as I am off to a conference all week.

As for jeelabs...perhaps.

if the format is simply as described here [http://www.domotiga.nl/boards/1/topics/1135], then i think no problems...
struct {
byte light; // light sensor: 0..255
byte moved :1; // motion detector: 0..1
byte humi :7; // humidity: 0..100
int temp :10; // temperature: -500..+500 (tenths)
byte lobat :1; // supply voltage dropped under 3.1V: 0..1
} payload;

sample output:
OK 16 1 84 191 0
OK 25 0 83 213 0
OK 57 0 83 213 0

...however I see the code does some bitwise operations and swaps the OK and LOW battery indicators so still need to look at that.

  For Each sLine In Split(sData, "\n")
    ' parse sensor data
    aScan = Scan(sLine, "* * * * * *")
    If aScan.Count = 6 Then
      iSensorId = aScan[1]
      iSensorId = IIf(iSensorId > 31, iSensorId - 32, iSensorId)
      iLDR = aScan[2]
      bPIR = BTst(CInt(aScan[3]), 0)
      iHumi = Lsr(CInt(aScan[3]), 1)
      iTemp = (((256 * (CInt(aScan[5]) And 3) + CInt(aScan[4])) Xor 512) - 512)
      iLowBat = Lsr(CInt(aScan[5]), 2) And 1
      sLowBat = If(iLowBat, "Empty", "OK")
      sMotion = IIf(bPIR, "Motion", "No Motion")
      If Main.bJeeLabsDebug Then
        Main.WriteDebugLog("[JeeLabs] Sensor ID: " & iSensorId)
        Main.WriteDebugLog("[JeeLabs] LDR      : " & iLDR)
        Main.WriteDebugLog("[JeeLabs] PIR      : " & sMotion)
        Main.WriteDebugLog("[JeeLabs] Humi     : " & iHumi)
        Main.WriteDebugLog("[JeeLabs] Temp     : " & iTemp)
        Main.WriteDebugLog("[JeeLabs] LowBat   : " & iLowBat & " (" & sLowBat & ")")
      Endif
      ' try to find device with address, and correct interface type.
      iDeviceId = Devices.Find(iSensorId, Devices.FindInterface("JeeLabs Interface"), "JEELABS NODE")
      ' if found then update it's value
      If iDeviceId Then
        Devices.ValueUpdate(iDeviceId, iTemp, iHumi, iLDR, sMotion)
        Devices.Battery(iDeviceId, sLowBat)
      Endif
    Endif
  Next

Oh, and thank you for making DomotiGa available to us all!

RE: ArduinIO thread - A generic(ish) arduino IO module for DomotiGa to make it easier to integrate arduino's - Added by pixi almost 5 years ago

This is very interesting :-)
i will follow this thread

Keep on working

Thanks Andreas H

RE: ArduinIO thread - A generic(ish) arduino IO module for DomotiGa to make it easier to integrate arduino's - Added by thechad almost 5 years ago

Thanks pixi.

It's basically all looking good so far...

Any suggestions on what to include? I was thinking the pattern matching for value1 value 2 etc would benefit from a regex like expression, but I can not for the life of me work out how to make a regex expression that that parses say the following input line into separate parameters...
IDAAABBBCCCDDD

Where AAA is value1, BBB Value2, CCC Value 3 and DDD Value 4

At the moment I rely on everything to the right of the regex match for the address (in the above case "ID ") as being the values and use a separator field eg. "," or ":" or even ",:" <-- will pick up either , or ;.

Would really love some feedback from people who use arduino's - or any serial device on what they would liek to see this module handle.

One thing I wish the design allowed for was multiple instances of an interface. As it stands I would need to duplicate everything I have done for this ArduinIO interface to have more than one arduino connected....ie a new interface name, device code, class, SQL tables etc etc. if i wanted to use two Arduino's...even though all this code would be exactly the same. Seems like there is a real opportunity to improve (redesign) the interface architecture.

Cheers.

RE: ArduinIO thread - A generic(ish) arduino IO module for DomotiGa to make it easier to integrate arduino's - Added by Alexie almost 5 years ago

@thecad:

Supporting multiple instances of an interface is on the today list, but we didn't had the time to work on it. If you want to clone it internally, to make multiple instances possible, try to use e.g. row=2 in SQL table and not create a new table.

BTW: There is an experimental trunk with more dynamic use of the Classes (aka interfaces), but is heavily outdated. In the future that should come in the current release. The current priority is the new WebGUI, if that's finished, we will have a look at this and also to support more then 4 values per devices.

RE: ArduinIO thread - A generic(ish) arduino IO module for DomotiGa to make it easier to integrate arduino's - Added by thechad almost 5 years ago

Thanks for the update Alexie. I am sure the team has it's hands full and great to know the idea is on the todo list.

I might focus on making sure the one Interface works and then look to clone it.

I wonder if I should consider changing the name to something like Generic Serial Interface?

Thoughts?

RE: ArduinIO thread - A generic(ish) arduino IO module for DomotiGa to make it easier to integrate arduino's - Added by rdnzl almost 5 years ago

Why only serial? With just a few lines of code it can talk to TCP sockets too.
Handy if you placed your serial device on the network via a serial<>tcp gateway.
See for example RFXCom interfaces, I can add that later if you want.
So a name like for example GenericIO comes to mind here ;-)

RE: ArduinIO thread - A generic(ish) arduino IO module for DomotiGa to make it easier to integrate arduino's - Added by thechad almost 5 years ago

Finaly got onto this and made some progress today.

  • renamed the interface, sql etc. to GenericIO,
  • updated the settings form and made it auto update the regex test results as you type (makes testing regex much easier and faster)
  • cleaned up some of the code
  • sorted out the auto-device creation.

So far so good.

Next step is to
  • add more documentation to the code
  • try to incorporate the TCP interface as suggested

Getting there...

RE: ArduinIO thread - A generic(ish) arduino IO module for DomotiGa to make it easier to integrate arduino's - Added by thechad almost 5 years ago

Getting closer...
Here you can see I have setup a "TCP server" (Hercules running on a Windows box) at 192.168.0.20
This is emulating a TCP device, eg. a serial to USB device or perhaps some other TCP server running on an Ethernet enabled Arduino or RasberryPi etc.

The DomotiGa interface has been set to TCP and told to connect to the server at 192.168.0.20 Port: 10001.

I have sent the string "R1=2" (with CR and LF) from the TCP device and it has been recieved and parsed into the device correctly....exactly the same as happens when the device is connected via serial.

So far so good. Still got to do more testing and coding, but it's looking good so far.

Question: this approach does rely on the end point device being an "always on" TCP server (this is what the RFXCom does). Is this what people want? Or do they want DomotiGa interface to be the server - as with iViewer interface?

RE: ArduinIO thread - A generic(ish) arduino IO module for DomotiGa to make it easier to integrate arduino's - Added by thechad almost 5 years ago

ok, I have integrated the GenericIO interface code into the current source (version 1337).

I think it's ok to be released...What's the best way to send it through?

Should I just zip and email the new/changed modules (~350kB) or just attach to a port here?
  • GenericIO.class
  • FSettingsGenericIO.class
  • FSettings.GenericIO.form
  • Devices.module
  • FMain.class
  • FMain.form
  • Main.module
  • mysql commands for new/changed tables
  • CIViewer.class which I have updated as a separate change to send a response to iViewer clients when a value changes

Anyone out there want to do some testing of it first using your serial or TCP devices? I'd be happy to attach the source code here for you to run from gambas (v. easy to do).

RE: ArduinIO thread - A generic(ish) arduino IO module for DomotiGa to make it easier to integrate arduino's - Added by thechad almost 5 years ago

Hi Guys, sorry to hear about the site issues.

On a positive note, looks like the genericio is working ok in the latest release (1339).

Keen to hear others thoughts on it now that it it at general release.

RE: ArduinIO thread - A generic(ish) arduino IO module for DomotiGa to make it easier to integrate arduino's - Added by ampman almost 5 years ago

It's working as the example above, I can send value from TCP server to domotiga. I think this part will be nice for what I plan to do.

But how does it works when it comes to write datas ? (from Domotiga to TCP server and then device)
It tried to create an event that set value1 to 10 for slave1 (adress |R1=| ), when I run the event, TCP server only receives "10" (the value). So how then do I know the destination device ?

ps : I am also using Hercules setup utility.

Thanks.
David

RE: ArduinIO thread - A generic(ish) arduino IO module for DomotiGa to make it easier to integrate arduino's - Added by thechad almost 5 years ago

Hi David.

Yes, that took me a while to work out too! This part of DomotiGa is not very well documented...but you are 99% of the way there.

Exec Summare: Put the full command in the to field ie. R1=10

Longer version....
You already have this part worked out, but for completeness (incase others are reading)...first a note on using Events to trigger commands.
As you have worked out, when you want to run a command on a device, you set the Action Type to "Set Device" and if the Value field is set to "Value1", the Events code will call SendCommand for the device - otherwise it calls ValueUpdate. So, to send a command. the value field must be set to "value1".

Note in the below code how Case 1 (ie Value field set to "Value1" is different)

Public Sub RunAction(iAction As Integer, iOrder As Integer, iEventId As Integer) As Boolean

  Dim rResultAction As Result
  Dim bOk As Boolean
  Dim sDeviceName, sResult As String

  rResultAction = Main.hDB.Exec("SELECT * FROM actions WHERE id = &1 ", iAction)
  If rResultAction.Available Then
    Select rResultAction!type
      Case 1 ' set device value
        ' only changing field Value will trigger interface code, and Value2-Value4 will only set field value
        If rResultAction!param1 And If rResultAction!param2 And If rResultAction!param3 Then
          sDeviceName = Devices.FindNameForDevice(rResultAction!param1)
          If Len(sDeviceName) Then
            Select Case rResultAction!param2
              Case 1
                bOk = Devices.SetDevice(sDeviceName, ParseText(rResultAction!param3))
              Case 2
                bOk = Devices.ValueUpdate(rResultAction!param1, "", ParseText(rResultAction!param3), "", "")
              Case 3
                bOk = Devices.ValueUpdate(rResultAction!param1, "", "", ParseText(rResultAction!param3), "")
              Case 4
                bOk = Devices.ValueUpdate(rResultAction!param1, "", "", "", ParseText(rResultAction!param3))
              Case Else
                Main.WriteDebugLog(("[Events] 3b. Invalid value field given ") & rResultAction!param2 & "!")
                bOk = False
            End Select

This code is in SetDevice in the Devices.module

    Case 49 ' GenericIO Interface
      If Main.bDevicesDebug Then Main.WriteDebugLog("[Devices] GenericIO Interface: Calling SendCommand with Address='" & sAddress & "' and command='" & sValue & "'")
      If Main.hGenericIO Then
        Main.hGenericIO.SendCommand(sAddress, sValue)
        ' Note: Unlike many of the above interface commands, this does not update the value.
        '       Value needs to be updated by the device we have sent the command to.
        '       ie. we send a command to turn on a relay. Device then responds that the relay is on (which updates Value).
        sText = ("Switched ") & sDeviceName & " " & sValue
      Else
        Main.WriteDebugLog(("[Devices] Can't control device '") & sDeviceName & ("' because GenericIO interface is disabled!"))
      Endif

So, finally to answer your original question, you just need to enter the full text of the command in the "To" field...ie. in your case R1=10

RE: ArduinIO thread - A generic(ish) arduino IO module for DomotiGa to make it easier to integrate arduino's - Added by ampman almost 5 years ago

Ok, I understand thanks to your good explanations, this should be ok for my application. Great job !

I have a question : in case the TCP server disconnects or is restarted, will Domotiga try to reconnect ?

David

RE: ArduinIO thread - A generic(ish) arduino IO module for DomotiGa to make it easier to integrate arduino's - Added by thechad almost 5 years ago

Hi. Glad it works for you.

Yes..try it with the debug log on and see for yourself :)

RE: ArduinIO thread - A generic(ish) arduino IO module for DomotiGa to make it easier to integrate arduino's - Added by sj3fk3 almost 5 years ago

This looks very promising.. I was just about to start hacking the jeenode code because I have some other sensors on it that I want to read.. Currently the jeenode code only works with vanilla roomnodes. So I guess this will work for jeenodes as well right? I have no clue how to start using it.. Should I wait? Or can somebody point me in the right direction?

RE: ArduinIO thread - A generic(ish) arduino IO module for DomotiGa to make it easier to integrate arduino's - Added by ampman almost 5 years ago

thechad,

I have finally developped a basic TCP server on my raspberry PI that connects to your GenericIO interface (not so easy and still not perfect ...). However, I noticed that using the web interface (the one in ...8080/domotiga/index.html), in the "Control" tab, when I click switch "ON" or "OFF", it only send "ON" or "OFF" trough TCP so it will not be possible have any slave adress information. Did you control you GenericIO class from this webinterface ?

I was think of using a intermediate event that will trig on this "ON" "OFF" state and send the correct frame (including adress of the slave) to a dedicated slave , it should work but it's quite complicated. Do you have any suggestions ?

Thanks,
David

RE: ArduinIO thread - A generic(ish) arduino IO module for DomotiGa to make it easier to integrate arduino's - Added by thechad almost 5 years ago

sj3fk3, it should work fine with any serial device. Just connect it up and configure it. You'll find the GenericIO interface under Interfaces/Input/Output/GenericIO.

You'll need to assign a regex rule to "match" the incoming data from the arduino (Jeenode). The only issue at the moment (and it's changing) is that you can only have one instance of the GenericIO interface running at any one time.

There is a Regex tester there in the interface so you can test the rules and there are loads of sites online to show you how to create a regex. (also see above for some examples)

ampman, I have not used the web interface to interact with DomotiGa (do not even know how to be honest!!!)
However, I assume it's the same as the normal DomotiGa GUI I am using.
I also assume you have set up the device as "switched" in the device options and so it appears as a button on the "Control" page in the DomotiGa gui.
I just tested this and got the below log output...which seems to match what you are observing....ie. 'On' is being output to the serial port and not "R1=1" as expected (in this case).
I assume you are expecting to see 'R1=1" as this is now a "switch" and you can only "switch" the first value, in this case the first value slot is defined as "R1=". (so you could never change the state of R2 or R3 or R4 using a button on the Control page as it ALWAYS controls the first value, R1 in this case.).

2013/11/14 18:19:53 [Devices] Interface for device with id '46' is '49'
2013/11/14 18:19:53 [Devices] GenericIO Interface: Calling SendCommand with Address='|R1=|R2=|R3=|R4=|' and command='On'
2013/11/14 18:19:53 [Devices] Interface with name 'GenericIO Interface' has id '49'
2013/11/14 18:19:53 [Devices] Device with address '|R1=|R2=|R3=|R4=|' is 'ArduinIO - Relays 1-4'
2013/11/14 18:19:53 [GenericIO] SendCommand 'On' to /dev/ttyUSB0

To be honest, I had not thought of using the "switch" option to control output for GenericIO.
All of my control has been via Events/Triggers/Actions and XMLRPC calls which gives me much more control over the cammands I am sending to the interface (ie. I use "13,10,1000" to toggle relay 10 for 1 second).

What would you expect/like it to send? "R1=1" or "R1=On" or....

RE: ArduinIO thread - A generic(ish) arduino IO module for DomotiGa to make it easier to integrate arduino's - Added by dnpwwo over 4 years ago

Hi thechad,

Nice work ! I was about to code my own TCP device handler when I realised that this might do the job for me. My only problem is that I need to put a <CR> on the end of my commands which your code doesn't do (because it is generic).

Do you know of a way of entering a CR into a text field with gambas via the UI? I tried the old Windows trick of <ALT>013 but the <ALT> was ignored and I just got '013'.

I need to send something like 'setstate,3:1,1<CR>', I also have the same issue coming back from the device where the terminator is also <CR> but your code looks for <LF> and the 'line' never completes.

Unix, Windows and Macs all treat end of line differently so I would propose that your 2 read routines look for; <CR>, <LF> or <CR><LF> as terminators to handle all cases.

Any thoughts?

RE: ArduinIO thread - A generic(ish) arduino IO module for DomotiGa to make it easier to integrate arduino's - Added by thechad over 4 years ago

Hi, thanks for the message.

You raise very valid points. I never really completed this module to my full satisfaction...and I hoped others would use it and provide me with feedback on what they would like to see, exactly as you have...and perhaps even enhance and release updates themselves ;)

I do like the idea of being able to set custom end-of-message tags both for send and receive...I think the best approach might be to update the interface settings form such that the user can set the eom string/character(s). This will mean a change to the database and associated code...so might take me a bit as I have some unfortunate family matters to deal with.

In the mean time, feel free to mod. the code for your own use (see here for some screenshots on how to do this as well as the wiki) or inclusion in the svn.

As for entering escape characters in the commands...you might try using /r (or perhaps you may need to double escape it //r ).

Cheers and thanks for using the module :)

1 2 (1-25/37)