• M
    malcolmbco

    Yes, UTF-16BE worked great. I have time updates going to two different devices every hour.

    Thanks!
    Malcolm

    posted in Scripting general Discussion read more
  • M
    malcolmbco

    You were correct, update context was set. I cleared it and the cron interval now works fine. I did change the data type to UTF16 and can read the rtc data back just fine. However, writing still seems to have an issue. The first word sent is always 0xFEFF and the rest of the data sent is truncated by one word. I checked this by sniffing the data stream on the modbus. Any ideas?
    Malcolm

    posted in Scripting general Discussion read more
  • M
    malcolmbco

    If I simply read the registers from the device, I get back what I expect. If I split the read into two 4 byte unsigned reads, then the data is correct in each part. I actually wrote the device code and am sure it works as intended.
    One more question: Is it possible to access the actual array of bytes read from the device if the point data is set to a fixed length string?
    This would really simplify my script processing of special data types.

    Thanks!

    Malcolm

    posted in Mango Automation general Discussion read more
  • M
    malcolmbco

    I am reading an 8 byte modbus parameters and it seems to be returning the least significant byte as a zero. Has anyone else had this issue?

    posted in Mango Automation general Discussion read more
  • M
    malcolmbco

    Philip,

    Thanks for the response.

    The registers are mapped as year, month, day of month, day of week, hours, minutes, seconds with the binary value in the lsb of each register. I made the data type a fixed length string so I could use String.fromCharCode to set them by position.

    I assigned a MetaDataSource with the cron set to once an hour to trigger the script. The script is as follows (the data point for the time is p18). I tested this on a windows platform and noticed that the cron setup does not seem to affect the execution, the script was being executed continuously until I made it only do the set on the hour turn over using an if statement. Is there an issue with cron on this platform?

    // set time in room controller
    
    var currentTime = new Date();
    
    var year = currentTime.getFullYear();
    var month = currentTime.getMonth() + 1;
    var dayOfMonth = currentTime.getDate();
    var dayOfWeek = currentTime.getDay();
    var hours = currentTime.getHours();
    var minutes = currentTime.getMinutes();
    var seconds = currentTime.getSeconds();
    
    if ((seconds === 0) && (minutes === 0))
    {
        var res = String.fromCharCode(0,year-2000,0,month,0,dayOfMonth,0,dayOfWeek,0,hours,0,minutes,0,seconds);
    
        p18.set(res);  
    }
    

    Thanks again!

    Malcolm

    posted in Scripting general Discussion read more
  • M
    malcolmbco

    I have a set of Modbus devices that I would like to send time syncs to. They accept the sync as a single type 16 Modbus message to a set of 7 registers. Can I use a Meta, Scripting or Virtual data source triggered every hour to do this? I have looked at the examples and there does not seem to be one that covers sending data to multiple registers in one stream. Any advice would be helpful here!

    posted in Scripting general Discussion read more