Comments (8)
Something like this should work. _WIN32 for be for any compiler on the Win32 platform (MSVC, MinGW, etc). If the problem is only related to the MSVC compiler, then it would be #ifdef _MSC_VER.
#ifdef _WIN32
strrchr(name, '') + 1;
#else
strrchr(name, '/') + 1;
#endif
.hc
from arduino.
How to handle 64-bit Windows?
from arduino.
On the work_machine (see P.S.) this code is not working:
#if defined WIN32 || defined WIN64 || defined _WIN32 || defined _WIN64 || defined __CYGWIN__ || defined __MINGW32__ filename = strrchr(name, '\\') + 1; #else filename = strrchr(name, '/') + 1; #endif
The only thing that **worked** was replacing this:
filename = strrchr(name, '/') + 1;
with this:
filename = strrchr(name, '\\') + 1;
As for 64-bit Windows I found this: According to [msdn](http://msdn.microsoft.com/en-us/library/b0084kay.aspx) the _WIN32 should be "Defined for applications for Win32 and Win64. Always defined.", but this "Most compilers targeting Microsoft Windows implicitly define _WIN32.[1] This allows code, including preprocessor commands, to compile only when targeting Windows systems. A few compilers define WIN32 instead. For such compilers that do not implicitly define the _WIN32 macro, it can be specified on the compiler's command line, using -D_WIN32." [Wikipedia](http://en.wikipedia.org/wiki/C_preprocessor#Conditional_compilation) has to be taken into consideration too.
basile
P.S.: I have in my possession two machines:
home_machine: Win7 32bit with VS2010 and arduino v1.0 and
work_machine: Win7 64bit with VS2010 and arduino v1.0.
from arduino.
would something like this work?
if (strrchr(name, '/') != NULL) filename = strrchr(name, '/') + 1; else filename = strrchr(name, '\\') + 1;
from arduino.
It works.
My Firmata.cpp has the following change and is reporting back "StandardFirmata" v2.3 (with StandardFirmata.ino loaded on the Arduino):
if (strrchr(name, '/') != NULL) filename = strrchr(name, '/') + 1; //points to slash, +1 gets to start of filename else filename = strrchr(name, '\\') + 1; //points to backslash, +1 gets to start of filename
basile
from arduino.
I found I had to do this as well on my Win7 64 bit machine. This is an issue that's be known about for 5 months but not fixed.
Is it actually really sensible to generate the Firmware string dynamically during run time based on file name? What are the advantages?
from arduino.
I edited a method "setFirmwareNameAndVersion":
void FirmataClass::setFirmwareNameAndVersion(const char *name, byte major, byte minor)
{
const char *filename;
const char *extension;
int len;
extension = strrchr(name,'.');
filename = strrchr(name,'/');
if(!filename)
{
filename = strrchr(name,'\\');
}
if(!filename)
{
filename = name;
}
else
{
filename++;
}
if(!extension)
{
len =strlen( filename );
}
else
{
len = extension - filename;
}
firmwareVersionCount = len + 2;
firmwareVersionVector = (byte *) malloc(firmwareVersionCount+1);
firmwareVersionVector[0] = major;
firmwareVersionVector[1] = minor;
strncpy((char*)firmwareVersionVector + 2, filename, len);
firmwareVersionVector[firmwareVersionCount] = '\0';
}
It's worked on my MSVC 2010 and Arduino Leonardo.
Good Luck!
from arduino.
updated in dev branch
from arduino.
Related Issues (20)
- Additional Firmata Java library
- Inconsistent state for additional analog pins (A6 - A11) on Arduino Leonardo HOT 1
- Pyfirmata and arduino leonardo mouse and keyboard abilities HOT 2
- T HOT 1
- Error compiling for board Arduino Uno. HOT 1
- Error compiling Firmata for board Arduino Nano Every HOT 8
- Error when compiling StandardFirmata 2.5.8 for Ardbox Analog HF + Wifi from Industrialshields HOT 2
- broken link in readme.md
- Last released version is from 2018 despite a lot of new work being merged HOT 10
- How to change TX RX pin for Nano HOT 3
- To drive a Servo what Capabilities do i need from a board? HOT 2
- Ethernet server mode versus client mode HOT 1
- Arduino HOT 1
- Arduino Nano Every doesn't report A6 and A7 on StandardFirmata HOT 3
- add Arduino UNO R4 MINIMA to boards.h please HOT 11
- [Question] How to add support for Jolly-dev to StandardFirmataWiFi HOT 9
- Firmata for Raspberry Pi Pico HOT 1
- Problem compiling firmata for Giga R1 Wifi board HOT 2
- Okay HOT 2
- No support for ESP32 based boards HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from arduino.