Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HelloWorld not sending string #21

Open
M47H3W opened this issue Oct 16, 2019 · 4 comments
Open

HelloWorld not sending string #21

M47H3W opened this issue Oct 16, 2019 · 4 comments

Comments

@M47H3W
Copy link

M47H3W commented Oct 16, 2019

Although sending a string from the calculator to the arduino works, I cannot get the arduino to send the "Hello World" message to the calculator. I am using the example HelloWorld project.

Am I doing something wrong or is it the program? I don't see any reference to send() in the HelloWorld.ino file

@KermMartian
Copy link
Owner

KermMartian commented Oct 16, 2019

Are you following the instructions at the top of the HelloWorld.ino to call Get(Str1) on the calculator? The Arduino can't send a string to the calculator without the calculator actively requesting it. Please see also the HIWORLD.8xp test program that contains Get() and Send() commands to interact with the Arduino.

I don't see any reference to send() in the HelloWorld.ino file

Because the Arduino only sends a string on the calculator's request, the "sending" is callback-driven. Take a look at the onRequest() function:

int onRequest(uint8_t type, enum Endpoint model, int* headerlen,
int* datalen, data_callback* data_callback)
{
if (type != VarTypes82::VarString) {
Serial.println("Received request for invalid data type");
return -1; // Can only return strings
}
String hello = "Hello, world! :)";
int rval = TIVar::stringToStrVar8x(hello, data, model);
if (rval < 0) {
return -1;
}
*datalen = rval;
memset(header, 0, sizeof(header));
TIVar::intToSizeWord(rval, header);
header[2] = VarTypes82::VarString; // Variable type
header[3] = 0xAA; // Variable name (tVarStr)
header[4] = 0x00; // ^ (tStr1)
*headerlen = 13;
Serial.println("Sending: " + hello);
return 0;
}

@M47H3W
Copy link
Author

M47H3W commented Oct 16, 2019

Thank you for the reply! I was utilizing the HelloWorld.8xp file which that comes in the same directory. The get(Str1 command is included but never works unfortunately.

After some more testing if I clear out the Str1 variable then it will always fail and say "Err: Unknown" on the calculator, but sending from the calculator to the arduino seems to work okay.

I recorded this YouTube video showing the program

The Str1 variable is only updated when it is set by the user for sending from the calculator to the arduino. When I opened the program on the calculator a 2nd time in the video, it failed with Get(Str1 and just ended up showing the old value which was set for sending from calc -> arduino

@M47H3W
Copy link
Author

M47H3W commented Oct 20, 2019

Small update: It appears that using the exact same configuration, the TI-84 Plus C Silver Edition works while the standard TI-84 Plus does not.

Additionally, setting a delay() inside onRequest() will delay the message being sent to the C Silver Edition while the standard TI 84 plus still takes the same amount of time to throw an error or return the wrong thing, so I guess this is a start.

I will attempt to see why this differs between the two but I'm not too experienced with this kind of thing.

@M47H3W
Copy link
Author

M47H3W commented Oct 21, 2019

I have figured out the issue and posted my findings on the forum. https://cemetech.net/forum/viewtopic.php?p=282700#282700

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants