|
Post by meijoa on Feb 21, 2018 15:56:04 GMT
Hi,
I tried to get a integer 0 - 255 from the serial console for dimming like in the Arduino example. Using "SerialASC.parseInt()" it didnt work at all.
What are the differences to the Arduino Board. Can I use just "Serial.begin(9600)" instead of "SerialASC.begin(9600)"?
|
|
|
Post by meijoa on Feb 21, 2018 16:34:54 GMT
Tried to solve it, but I get an Error compiling "'isDigit' was not declared in this scope". But this should normally work?
|
|
|
Post by Admin on Feb 21, 2018 19:06:36 GMT
isDigit() is in the header file WCharacter.h. This is currently not included in the ShieldBuddy but we will add it in the next release. In the meantime, add #include "Wcharacter.h" to your sketch and copy the attached Wcharacter.h to C:\Program Files (x86)\Arduino\hardware\aurduino\aurix\cores. WCharacter.h (4.46 KB)
|
|
|
Post by meijoa on Feb 21, 2018 23:18:55 GMT
Thank you, really appreciate your support. Do you know something about "Serial.parseInt()" issues too?
|
|
|
Post by Admin on Feb 22, 2018 7:35:01 GMT
Hi,
The serial port (and stream) functions in the ShieldBuddy are based on the Arduino Due. The parseInt() is a new function which we have not added yet. You could try adding the attached files to C:\Program Files (x86)\Arduino\hardware\aurduino\aurix\cores like you did with Wcharacter.h. This might work. We will fix this in the next release.
Stream.cpp (8.59 KB) Stream.h (5.91 KB)
|
|
|
Post by radisc on May 22, 2019 14:19:50 GMT
I'm having a similar problem, i tried to send a float from the serial monitor, in the form BX.Y , however when the code arrives to parseFloat/Int the shieldbuddy simply freezes
Here is my code
void receiveAndParse(){
if (SerialASC.available()){
if (SerialASC.read() == 'B' ){
nav_steer = SerialASC.parseFloat();
if(SerialASC.read() == '\n'){ }
}
}
}
|
|
|
Post by Admin on May 23, 2019 7:55:48 GMT
We will check this!
|
|
|
Post by Admin on Jul 12, 2019 13:36:54 GMT
We have found out why the ParseFloat() fails. This is caused by a difference between the serial port behaviour of the Aurix compared with the AVR. We will fix this in the next release. The attached library will fix the problem now: www.hitex.co.uk/fileadmin/uk-files/downloads/ShieldBuddy/libAurduino.aCopy this to: C:\Program Files (x86)\Arduino\hardware\aurduino\aurix\variants\tc275 and; C:\Program Files (x86)\Arduino\hardware\aurduino_Dx\aurix\variants\tc275
|
|
|
Post by deadman1966 on Oct 18, 2019 5:47:42 GMT
We have found out why the ParseFloat() fails. This is caused by a difference between the serial port behaviour of the Aurix compared with the AVR. We will fix this in the next release. The attached library will fix the problem now: www.hitex.co.uk/fileadmin/uk-files/downloads/ShieldBuddy/libAurduino.aCopy this to: C:\Program Files (x86)\Arduino\hardware\aurduino\aurix\variants\tc275 and; C:\Program Files (x86)\Arduino\hardware\aurduino_Dx\aurix\variants\tc275
I have made the changes but still have code that locks up on the parseInt function.
It never gets to this line in the code which should print out the integer it just got from the serial term.
SerialASC << y << F(" input") << endl;
static time_t tLast; time_t t; tmElements_t tm;
// check for input to set the RTC, minimum length is 12, i.e. yy,m,d,h,m,s if (SerialASC.available() >= 12) { // note that the tmElements_t Year member is an offset from 1970, // but the RTC wants the last two digits of the calendar year. // use the convenience macros from the Time Library to do the conversions. int y = SerialASC.parseInt(); SerialASC << y << F(" input") << endl; if (y >= 100 && y < 1000) SerialASC << F("Error: Year must be two digits or four digits!") << endl; else { if (y >= 1000) tm.Year = CalendarYrToTm(y); else // (y < 100) tm.Year = y2kYearToTm(y); tm.Month = SerialASC.parseInt(); tm.Day = SerialASC.parseInt(); tm.Hour = SerialASC.parseInt(); tm.Minute = SerialASC.parseInt(); tm.Second = SerialASC.parseInt(); t = makeTime(tm); SerialASC << F("RTC set to: ")<< endl;; RTC.set(t); // use the time_t value to ensure correct weekday is set setTime(t); SerialASC << F("RTC set to: ")<< endl;; printDateTime(t); SerialASC << endl; // dump any extraneous input while (SerialASC.available() > 0) SerialASC.read(); } }
t = now(); if (t != tLast) { tLast = t; printDateTime(t); if (second(t) == 0) { float c = RTC.temperature() / 4.; float f = c * 9. / 5. + 32.; SerialASC << F(" ") << c << F(" C ") << f << F(" F")<< endl;; } SerialASC << endl; }
|
|
|
Post by Admin on Oct 18, 2019 11:02:06 GMT
The parseInt() and parseFloat() functions should now work:
void setup() { // put your setup code for core 0 here, to run once:
SerialASC.begin(9600); SerialASC.println("Hi");
}
float volatile FloatVal; int volatile IntVal;
void loop() { // put your main code for core 0 here, to run repeatedly:
if (SerialASC.available()){
if (SerialASC.read() == 'B' ) {
FloatVal = SerialASC.parseFloat();
IntVal =SerialASC.parseInt(); SerialASC.println(FloatVal); SerialASC.println(IntVal);
} } }
|
|