FOUND IT! ( I think)
Having almost eliminated it being a serial problem as such, I went back and looked at the logs and every time things stopped working there was always something like
Code:
Received Meridian Response:
Meridian Response Length = 0
Received Meridian Response: Longe ¬@j8
Meridian Response Length = 12
So I looked at my plugin code here;
Code:
ReceiveResponse = function (self)
if not self.code then
print('Code is nil!!!')
elseif self:IsDataAvailable() and self.data then
print('Received Meridian Response: '..self.data)
print('Meridian Response Length = '..string.len(self.data))
if string.len(self.data) > 0 then
local _, _, prefix, value = string.find(self.data, '^(%w-)%s+(%d-)$')
if prefix then
print('Returned prefix:', prefix)
if string.upper(prefix) =='MUTE' then
self:Notify('Processor', 'Mute', 'On')
end
end
if tonumber(value) then
print("Meridian Volume Received = "..value)
self:Notify('Processor', 'Volume', value)
self:Notify('Processor', 'Mute', 'Off')
end
end
Super.ReceiveResponse (self)
end
end,
I remembered having to add the "if string.len(self.data) > 0 then" because the string.find was failing with errors when the length was 0, so then I wondered if the "Super.ReceiveResponse (self)" was also having issues with a zero length string.
So I changed my code to this
Code:
ReceiveResponse = function (self)
if not self.code then
print('Code is nil!!!')
elseif self:IsDataAvailable() and string.len(self.data) > 0 then
print('Received Meridian Response: '..self.data)
print('Meridian Response Length = '..string.len(self.data))
local _, _, prefix, value = string.find(self.data, '^(%w-)%s+(%d-)$')
if prefix then
print('Returned prefix:', prefix)
if string.upper(prefix) =='MUTE' then
self:Notify('Processor', 'Mute', 'On')
end
end
if tonumber(value) then
print("Meridian Volume Received = "..value)
self:Notify('Processor', 'Volume', value)
self:Notify('Processor', 'Mute', 'Off')
end
Super.ReceiveResponse (self)
end
end,
and low and behold no more problems.
I expected the "elseif self:IsDataAvailable() and self.data then" line to trap this, but maybe it doesn't or maybe there is data but it's not something the "Super.ReceiveResponse (self)" or string handling routines can handle????
Richard