SetCommMask() ERROR Invalid argument (22)

I have an application that uses relays to control AC Contactors (coil is 120v) and they seem to work for sometime. After running my sketch with the relays, several times, I get disconnection from the serial port. The following continuous message appear on the command prompt of the serial connection:

SetCommMask() ERROR Invalid argument (22)

If I close the serial command prompt window (containing the serial connection) and run again the Cayenne-ser.bat batch file, it starts working again for sometime and then I get the same error. Have you seen this before? Not sure if it started after one of the Windows updatesā€¦

@adam @eptak tagging for this.

Sorry, I have only used the serial connection method a few times. May I ask why you are using it? Itā€™s meant more for testing/debugging than to be a ā€œproductionā€ solution.

Hi Adam,

Iā€™m using a Latte Panda board, which is a Windows 10 Home computer with a built-in Arduino Leonardo. The board has Wireless and Ethernet ports, but they ā€œbelongā€ or can be seen by the Windows 10 OS. As far as I know, using the serial connection is the only way to connect to the Cayenne Portal. The Latte Panda has like a ā€œvirtualā€ serial port connection for the built-in Arduino Leonardo. That is the reason Iā€™m using the serial connection.

I guess it really depends on what youā€™re trying to do and at what level. I donā€™t have a LattePanda so Iā€™m not quite sure how it works or what sensors/devices you are using and how they are connected. Are you able to get everything you need through the windows 10 OS? If so, you can use a program/script in the Windows 10 OS to send the data using the MQTT API.

1 Like

Hi Adam,

Just to let you know that it seems I found what was causing the issue. Between reading and contacting the relay supplier, we were able to narrow the problem to induction noise. I bought two induction suppression caps and the SetCommMask() error disappear!

1 Like

Thanks for posting back!