Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor Serial mock away from a singleton #23

Open
jacobrosenthal opened this issue Feb 11, 2015 · 5 comments
Open

Refactor Serial mock away from a singleton #23

jacobrosenthal opened this issue Feb 11, 2015 · 5 comments

Comments

@jacobrosenthal
Copy link

I have need with several of my libraries to spy on 2 serial at at time, and Arduino has software serial and 2 hardware serial on many boards now.

Is there a reason Serial mock is a singleton?

@ikeyasu
Copy link
Owner

ikeyasu commented Feb 11, 2015

I just don't know that Serial class could be multiple instances. (I am a user of Uno and Pro Micro.)
You mean we should have Serial1, 2, 3 like http://arduino.cc/en/reference/serial ?

@jacobrosenthal
Copy link
Author

Sure that exists on arduino so our mock should support it.

Further for me, I have a bunch of Serial tools that Im testing. I have
tools that split the stream into 2 , or combine 2 streams into 1. Tools
that take a stream and print it as hex so its easy to debug.

All of these I need to be able to spy 2 serial at the same time.

On Wed, Feb 11, 2015 at 1:04 AM, IKEUCHI Yasuki [email protected]
wrote:

I just don't know that Serial class could be multiple instances. (I am a
user of Uno and Pro Micro.)
You mean we should have Serial1, 2, 3 like
http://arduino.cc/en/reference/serial ?


Reply to this email directly or view it on GitHub
#23 (comment).

@ikeyasu
Copy link
Owner

ikeyasu commented Feb 12, 2015

I may understand that Serial should not be a singleton. If you don't mind, could you give me a sample using multiple Serial instances? Or could you create patches for Serial Mock?

@jacobrosenthal
Copy link
Author

Hrm. Been playing around for a day or so. I dont necessarily need it not to be a singleton. For Serial1, Serial2 etc can just duplicate the class. I do need it to be a proper Stream class though so it can be passed to things that take Serial... Still trying things.

@ikeyasu
Copy link
Owner

ikeyasu commented Feb 16, 2015

Yeah, I read your implementation for TapStream. I understood that it should not be Singleton.

jonathanperret pushed a commit to jonathanperret/arduino-mock that referenced this issue Aug 25, 2024
* add test setup
* Transform static variable into class property
* Add a define to disable #warnings
* add unit tests for encoders
* tests: Add documentation

Co-authored-by: stla <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants