Skip to content

Commit dcfa045

Browse files
committed
zephyrSerial: fix ambiguity in print float
Also update the print base function to return as it is value for octal. Also document what is left to be done. Signed-off-by: Dhruva Gole <[email protected]>
1 parent 2e6f9f4 commit dcfa045

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

Diff for: cores/arduino/zephyrSerial.cpp

+6-3
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ size_t arduino::ZephyrSerial::print(const int val) {
3030
}
3131

3232
size_t arduino::ZephyrSerial::print(double d) {
33-
printk("%0.4f",d);
33+
printk("%.2f",d);
3434
return sizeof(double);
3535
}
3636

@@ -40,14 +40,17 @@ size_t arduino::ZephyrSerial::print(const int val, const int base) {
4040
} else if (base == 16) { /* print Hex value */
4141
printk("%x",val);
4242
} else if (base == 8) { /* Todo: print octal value */
43-
printk("%x", val);
43+
printk("%d", val);
4444
} else if (base == 10) { /* print decimal value */
4545
printk("%d", val);
4646
} else {
4747
return EINVAL;
4848
}
4949

50-
return 1; /* Always return 1 byte */
50+
return 1; /* temporarily return 1 byte, but change this to
51+
* return strlen(buffer);
52+
* when we implement octal and binary
53+
*/
5154
}
5255

5356
size_t arduino::ZephyrSerial::println(char ch){

0 commit comments

Comments
 (0)