hlfshell / serial-synapse-socket

Given a synapse object, create a socket server for the device
0 stars 0 forks source link

TimeoutFnc call results in undefined error #2

Open Macgyverman opened 7 years ago

Macgyverman commented 7 years ago

Hello, I was attempting to set a timeout function on a call, but kept getting an undefined error.

I believe the problem is caused by line 145, we should change executingFnc.timeout = setTimeout(self._waitingResponse[fncName].timeoutFnc, self._commands[fncName].timeout);

to executingFnc.timeout = setTimeout(self._commands[fncName].timeoutFnc, self._commands[fncName].timeout);

Also, the manual mentions this function will be called with "Timeout occured", but no parameter is passed.

hlfshell commented 7 years ago

Thanks for the bug report! I will investigate!

hlfshell commented 7 years ago

line 145 in what code?

Is this a serial synapse problem or a serial synapse socket problem?

Macgyverman commented 7 years ago

Hi Keith,

Sorry for the lack of context, I guess I was still in coding mode. The issue is with regards to serial synapse. I didn't submit it on the project page, as it's a follow-up to the quoted email below (exchange you and I had about the same issue in January)

Essentially, we were chatting about making serial synapse commands compatible with CMDMESSENGER. Since serial synapse requires the uuid as the first parameter, one can't use the SendCMDstart command in CMDMESSENGER. However, while working out bugs this weekend (arduino responses were being ignored) I eventually found out that the current syntax actually makes it impossible to use Any CMDMESSENGER start or end functions (I had been building my responses using a serial.print for the uuid then using the standard SendCMDarg and sendCMDend functions.

I found out the sendCMDend fails silently if you never send a SendCMDstart (which can't be done with the current serial synapse syntaxe, as doing so automatically sends an integer commandid as the first argument and you expect a uuid)

The code I sent along allows the library to default to your syntaxe (uuid first), but if the first argument is not a valid uuid (an integer command Id for example) it moves on to the next argument to check for a valid uuid.

In this manner, CMDMESSENGER code can stay standard (SendCMDstart,SendCMDarg, sendCMDend) while maintaining compatibility with your existing code.

Another note : your example code assumes \r\n is sent at the end of every message. The current version of CMDMESSENGER needs to have this enabled by calling printLfCr(true) , as by default no \r\n is sent.

Hopefully this clears it up a bit.

Sorry about any odd syntaxe, I'm on my iPhone at the moment.

Regards,

Pierre

On Jun 4, 2017, at 10:47 AM, Keith Chester notifications@github.com wrote:

line 145 in what code?

Is this a serial synapse problem or a serial synapse socket problem?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or mute the thread.