how would I send a string like
"track1:2323;"
via Serial?
sdPut(&SD2, "track1:2323;" );
gives me a error.
how would I send a string like
"track1:2323;"
via Serial?
sdPut(&SD2, "track1:2323;" );
gives me a error.
My guess is that sdPut expects a single byte as the second argument, not a pointer to a string.
C:\PROGRA~2\Axoloti\app/chibios/os/kernel/include/chqueues.h:312:61: error: invalid conversion from 'const char*' to 'uint8_t {aka unsigned char}' [-fpermissive]
#define chOQPut(oqp, b) chOQPutTimeout(oqp, b, TIME_INFINITE)
^
C:\PROGRA~2\Axoloti\app/chibios/os/hal/include/serial.h:183:23: note: in expansion of macro 'chOQPut'
#define sdPut(sdp, b) chOQPut(&(sdp)->oqueue, b)
^
C:\Users\ADMINA~1\DOCUME~1\axoloti/build/xpatch.cpp:95:2: note: in expansion of macro 'sdPut'
sdPut(&SD2, "fsdsdf");
^
C:\PROGRA~2\Axoloti\app/chibios/os/kernel/include/chqueues.h:365:9: note: initializing argument 2 of 'msg_t chOQPutTimeout(OutputQueue*, uint8_t, systime_t)'
msg_t chOQPutTimeout(OutputQueue *oqp, uint8_t b, systime_t time);
^
make: *** [C:\Users\ADMINA~1\DOCUME~1\axoloti/build/xpatch.bin] Error 1
shell task failed, exit value: 1
Compiling patch failed ( C:\Users\adminator\Documents\axoloti\axoloti-factory\objects\gpio\serial\serial.axh )
hmm.. is it possible to send strings here?
I can send strings through serial from a arduino, so..
Of course you can send a string. If there's nothing which specifically handles sending a string, create a loop which iterates through the string, sending one character at a time.
Hi, try with
sdWrite(&SD2, text, 32);
Number "32" is the length of bytes to be sent. It's mandatory. sdWrite doesn't care about a string's terminating 0-byte.
Hi
I get the same error:
error: invalid conversion from 'const char*' to 'const uint8t* {aka const unsigned char*}' [-fpermissive]_
while doing
sdWrite(&SD2, "comeOn", 32);
I DID IT !!
char data[] = "x/Hello World!;";
sdWrite(&SD2, (uint8_t *) data, strlen(data));
but how would I get the value of my inlet1 (in1) into this char-array? ..
No, it is a integer.
I get some values at both inlets of the script/script2-object. Now I need to send them to the Arduino like
track1:343;
track2:432;
you will need to convert it to a string. there are f to s converters in the community library i think, so maybe look at those.
generally i would advice you though to send as little data as possible through serial and convert it to a string on the arduino. track1: 343 could just be 1 343 for example. you will have to figure a scheme out for yourself but pretty much everything will be better then sending the full ascii characters
I cant find this f to s converter.. do you know ne name?
I try sendig static values for now, but something still is a little "broken" ..
On Axoliti I do:
void setup(void) {
}
void loop(void) {
char data[] = "t1:222;";
char data2[] = "t2:444;";
sdWrite(&SD2, (uint8_t *) data, strlen(data));
sdWrite(&SD2, (uint8_t *) data2, strlen(data2));
while(!sdGetWouldBlock(&SD2)) {
out1 = sdGet(&SD2)<<21;
}
chThdSleepMilliseconds(3);
}
.. and on Arduino I do simply:
if(Serial.available()) {
cmd = Serial.readStringUntil(';');
Serial.println(cmd);
}
.. now look what I get:
2t1:222
t2:444
t1:222
t2:444
t1:222
t2:444
t1:222
t2:444
t1:222
t2:444
:222
t2t1:222
44
t1:2:444
t1t2:444
22
t2:4:222
t2
t1:22244
t1:22:444
t2:444
t222t1:222
t24
t1:222
44
2:444
t1:2:4
t2:444
t2
t2:444
t:222
t21:222
t2:44
t1:44
t1:2444:444
tt2:444
t2:444t2
t2:444t2:4442:444
t1444
t14
t1:2t1:222
t2:44t2:444
t
t1:222tt1:2:444
t1:222
t2:4422
t2:
t1:2:444
t1:222:444
t1:2222:2:444
t1:222
t2:2:444
t:444
t1:222
44
t1:222
t2:444
t1:1:222
t2:444
t
what could cause this. I do communicate between multiple Arduinos/Teensys on other projects without problems. -.-
Does increasing the chThdSleepMilliseconds(3) have any effect? I suspect you're seeing buffer overrun.
glad it works!
but it kind of confirms my initial statement...
you are sending 6 bytes at a time, where you could probably get away with 2 or 3, thus eliminating the buffer overrun in the first place
As lokki wrote, reducing the amount of data can be useful, but it’s not the complete solution.
Reliable serial data between systems needs full understanding of what’s happening on both sender and receiver, buffer sizes, blocking or non-blocking drivers, checking return codes, etc. Even then, it’s sometimes necessary to use message framing and CRC checking to eliminate spurious messages.