Using acquireSerialBuffer()

I’ve been reading up on what I can find about acquireSerialBuffer() but I’m still stuck.
First, it seems like when I use acquireSerialBuffer() it doesn’t do anything. I’m assuming that this is for the USB Serial connection referred to as just Serial (not Serial1 in this case). Is that correct?
If so, can someone post a bit more example code on using it? It doesn’t seem to be working for me, as if it’s just being ignored.

Second, if using acquireSerialBuffer(), I’m assuming I can look at those buffers directly instead of having to use Serial.read(). Is that assumption correct?
If that is, how do I reset the value returned by Serial.available()? It seems like calling read() is the only way to increment the pointer.

Thanks in advance!

The sample uses two static local buffers which will only be available via the returned conf object.
But I guess you could also pass a global buffer which you’d have direct access, but since you have not way of accessing the head/tail indexes of the circular buffer the USBSerial object uses to push and pop bytes there will be little use in that.

1 Like

Thanks ScruffR.
I was playing around last night with the USB_Hal files looking at the head/tail indexes.
Is there a better/faster way to update the Photon with any changes to those core files other than running “make PLATFORM=photon clean all program-dfu” from the Cygwin terminal? I’m not used to the command-line stuff.

Not really

Ok.
Thanks again ScruffR.
One final question.
What is the max transfer speed on Serial, or what determines it?

Since this is only a virtual com port (USB CDC) there is no actual baud rate as the communication runs via USB report “packets” and not as raw RX/TX communication with start, parity and stop bit.
I’d think the limit for report transfer would be at 12MBit, but for actual facts you may want to consult the STM32F2 datasheet.

1 Like