end2endzone / win32Arduino

win32Arduino is a windows/linux implementation of many arduino functions to allow an arduino library developer to unit test code outside of the arduino platform.
MIT License
2 stars 2 forks source link

win32Arduino on Linux #15

Closed sidey79 closed 6 years ago

sidey79 commented 6 years ago

Is there any chance to get rid of the win32 specific libs / functions used in this lib?

I wanted to run some integration tests with travic ci but there are serval things missing.

end2endzone commented 6 years ago

That's a good idea and I had this planned for a long time. I am locally working on porting all scripts from /ci/appveyor to /ci/ant to have cross-Platform scripts. However, I do not have much experience programming in Linux (I do own a Raspberry Pi & a Ubuntu partition).

I do not know how many sections of the library would be impacted by the change but I think it would be possible without too much work. Nothing that a google search can't fix.

end2endzone commented 6 years ago

I think it would be a matter of wrapping each function implementation with #ifdef statements. See stackoverflow for details.

end2endzone commented 6 years ago

I would be glad if you give me a hand on this and help me porting the code to linux. Feel free to send me a pull request.

sidey79 commented 6 years ago

I am not so familiar with all the win32 libs.

I think, there are std cpp libs which are available crossplattform.

But win32arduino usues win32 specific libs.

There are some very easy to fix T things.

end2endzone commented 6 years ago

@sidey79 I would appreciate your help for issue #17.

end2endzone commented 6 years ago

@sidey79 The code is now able to compile without errors on the Raspberry Pi. However, I am not able to compile on Travis CI.

The following error is displayed in the Travis CI build log:

     [exec] /home/travis/build/end2endzone/win32Arduino/src/win32Arduino/arduino.cpp: In function ‘void randomSeed(int16_t)’:
     [exec] /home/travis/build/end2endzone/win32Arduino/src/win32Arduino/arduino.cpp:926:3: error: ‘::srand’ has not been declared
     [exec]    ::srand(value);

I do not have enough experience for fixing the issue. Does it mean that srand() definition is located elsewhere? Can you take a look at it?

sidey79 commented 6 years ago

@end2endzone You are fast..

I haven't tested it, but the function you try to call, seems not to exist:

https://github.com/end2endzone/win32Arduino/blob/fce016a6cae8fc7253f549a3571e456330562e0c/src/win32Arduino/arduino.cpp#L926

Not sure, what the compiler does with this style of coding, but srand and rand should be located in stdlib: http://www.cplusplus.com/reference/cstdlib/srand/ http://www.cplusplus.com/reference/cstdlib/rand/

sidey79 commented 6 years ago

Fixes are here:

18

end2endzone commented 6 years ago

Fixed in 623f317