MyRobotLab / myrobotlab

Open Source Java Framework for Robotics and Creative Machine Control
Apache License 2.0
227 stars 106 forks source link

MrlComm failing Esp8266 build due to missing method in Msg.h and Msg.cpp #769

Open jordandmc opened 3 years ago

jordandmc commented 3 years ago

Describe the bug When attempting to compile MrlComm on the Develop branch using the Arduino IDE I get the following error: MrlComm.cpp:170:21: error: no matching function for call to 'Msg::begin(WebSocketsServer&)'

To Reproduce Steps to reproduce the behavior:

  1. Open MrlComm.ino
  2. Set your board to any one of the Esp8266 boards
  3. Click Verify
  4. See error

Expected behavior I expect that I should be able to compile the MrlComm and upload it to my Esp8266 board and it would communicate with MyRobotLab via WebSockets.

Screenshots image

kwatters commented 3 years ago

Cool! Ok, very cool use case. There is a compilation error here clearly. The generated msg class isn't expecting a WebSocketsServer, but rather it's expecting a serial port.

(in Msg.cpp you see the following method.)

void Msg::begin(HardwareSerial& hardwareSerial){ serial = &hardwareSerial; }

So.. that's the beginning of this issue.. next is that when other messages are published, they need to know how to write to the web socket, instead of writing to a serial port... I suspect we'll need to sort that out. right now, it just writes a byte array to the serial port for each message. (maybe websockets will have the same exact data format ? one websocket message per mrlcomm message being published. )

Getting this to work with either a serial port or a websocket will require a little bit of refactoring of the Msg.cpp/.h so they can write to either a serial port or a websocket. (these files are generated by the java code in the main method of ArduinoMsgGenerator.java. ... )

lastly, we need to define a behavior of what happens when a client is connected to the websocket... (this is a little different that opening a serial port.. in that opening a serial port on a normal arduino will cause the board to reset. we probably do not want the same behavior for websockets...)

Thanks for reporting this issue! There have been conversations in the shoutbox recently about just this topic...