Cannot Send or Receive Serial from Max
I am helping a student connect an ESP32 to max via USB, which I have done many times before, but this time it is not working. I can see the ESP32's port when I send a print message to the serial object, but I never get any data in Max 8.6.5, Max 8.5.6 or Max 8.3.1. I do not receive any errors, either. If I print the output from the status outlet, I am getting "status: read 0" messages at the polling rate. I am able to receive what the esp32 is sending with Pd, CoolTerm and the Arduino Serial Monitor (of course not at the same time). I am on a M2 Macbook with OSX 12.4 Monterey. I have read many forum posts about this, and nothing seems to help. I am sure I am overlooking something, but I just can't see it. Some other notes:
I only have Max open when I am testing
The baud rate is the same in Max and the arduino sketch (9600)
The correct port is selected.
The USB cable works for data transfer.
I will attach some example code I am testing with instead of the stuff I was specifically trying to accomplish. The example works for Pd, and I can also get the ESP32 data in coolterm. Again, nothing I do seems to work in Max. I'm puzzled. Please advise.
Ok, something (else) puzzling happened: I had the max example that I attached above open, and it was still not working. The ESP32 was connected and sending. I then opened Arduino and its serial monitor. Strangely enough, I was seeing the ESP32's data stream even though I had already opened the port in the Max example. When I closed the serial monitor, all of a sudden max started receiving values. I can also make this happen with cool term. If I close the max serial port and reopen it without using another application, it will again not receive data. See for yourself:
try to toggle dtr.
some ESP32 boards get reset and enter download mode after port
gets reopened.