Do you want to use this with a computer or with an external device?
If you are just trying to connect the calculator to the computer, the calculator should pretend to be a serial device itself, and the computer should recognize it as a /dev/ttyACM device (on Linux) or a COM port (on Windows). Admittedly, I haven't tested the library much on Windows, so it's possible that I'll have to adjust the device descriptors before Windows will recognize it properly.

1. If you're directly connecting it to a computer, there is no real serial line involved aside from the USB cable, which is using an entirely different baud rate and format anyway, so the baud rate is irrelevant. I think it defaults to 9600 baud, and if you want to change it you can use srl_SetRate.

2. The example was intended to be used with the calc directly connected to a computer over USB, but it should work with physical serial devices if the baud rate is set. I probably should test it on Windows, but that's been low-priority for me as I have a Linux computer.
An external device for now, but a computer for more complex experiments.

My little python sketch works in Windows and Linux (mainly because it rested in a thumb-drive with some other programs as I bounced from machine to machine) so I'll try running it in Raspbian and Ubuntu, just to see what happens. Windows does still recognize the calc, but device manager seems to get confused and doesn't understand what it's doing, so your descriptors may be a little off, but the fact that it still sees the calc is good.

I'll be testing with some arduino and esp32 systems too, mainly because they tend to be more predictable in performance (although my basic code is still too hefty for anything but an arduino mega right now, so most work has been spent debugging and shrinking). Thanks for the help! I'll see what I can do about OS testing.
Ran some test, took some old drives 'n .iso's to test your descriptors:

Works in:
-Ubuntu (obviously)
-Raspbian
-Mac OS
-Windows 10 IOT Core

Doesn't work in:
-Windows 10

I can test more if necessary, such as Chrome OS, all the Windows, etc. I believe that Linux and its ilk work fine, Windows doesn't open a COM immediately, although Windows IOT does.

You say that baud doesn't matter with PC's, but it does, it just defaults to 9600 as standard. In the Windows device manager you can manually configure baud of each port (if you're doing something finicky I suppose) so I assume there is a way to do it in Linux as well, although I don't use it often. I'll try running my scripts on some Linux VMware or remote desktops. If you need me to pull some Windows descriptors for you I can get them.
I have a (janky) idea for getting the calculator to communicate to any PC... but it isn't working yet.

The Arduino Mega (and a few other boards) has multiple pairs of serial pins, and is capable of running multiple ports. I planned on using this for some sort of serial hub or extremely powerful device (speech synthesizer?) but this is better for now. The issue is that neither the arduino or the calc recognize each other as a serial device. So my plan is simple: have the calc and Arduino reading and writing data waiting for a response, which I have done between Arduinos before, and having them activate each other when they connect. The Arduino part is a breeze, but the calc side is the problem. The calculator can't seem to send serial data without initializing it's USB first, which it can't do with an Arduino. Trying to read or write data ends in spectacular crashes that *almost* brick the calc (screen has aneurysm, goes black, stays dead until reset held for about 4 seconds). I can't figure out how to force the calc to send data or attempt to read from port without crashing, both plugged and unplugged from the Arduino. Is there an override or try-except system I should use?

Oh, and the descriptor idea would end up like a stream of "/?;" every second until, say, a soundcard replies with: "/d:SC/v:2.4/2;" for /description: SoundCard, version 2.4, supports 2 tracks for polyphonic sound, end of description.
Any updates on adjusting the serial device descriptors to get Windows to recognize the calc properly?
I was able to get it to work by using two arduinos as serial relays, but it would be nice to skip those and communicate directly between windows and the calculator
Quote:
I was able to get it to work by using two arduinos as serial relays


Neat, my janky idea had some merit after all! As far as I can tell, Windows can't detect the calc running serial, so no ports are opened to the device.

However, I have two questions for you Dmalenke: Why two arduinos? Are you using one to receive from the calc and another to send to the PC, with intercommunication using pulse()? And also, what does your calc code look like? I'd like to see a copy of what works, since most of my code either instantly resets the RAM, bricks the calc for a little while until it resets, or plays havoc with the display. I've discoverd at least 19 ways that don't work.
As far as I can tell, Windows isn't able to see the calc as a serial device because the driver for TI-Connect CE overrides it. Uninstalling TI-Connect CE would fix that, though that's obviously not a real solution.
I guess I could change the device ID so that Windows can't tell that it should use the TI-Connect driver - it would almost definitely work, but might not be the best solution for the problem.
Here's the library set up to use a different device ID - I'm too lazy to test right now, but it should work on Windows. Once again, I'm not sure if this is the best solution, but it should at least work for now.
King Dub Dub, each arduino only has one usb port, so I'm using one to connect to the calculator, then one to connect to my computer.
https://engineeringprojectshub.com/serial-communication-between-nodemcu-and-arduino/
Here's an example of what I'm doing.
Your crashing issues are due to the serial buffer overflowing.. I think. ( I honestly don't know much about C. I mainly use C# )
Try increasing the buffer size, or call srl_Init before the buffer fills.


Code:

     if(true){

     //reinit to prevent memory overflow and crash 
  srl_error = srl_Init(&srl, usb_device, srl_buf, sizeof(srl_buf), SRL_INTERFACE_ANY);
   if(srl_error) goto exit;
    srl_Write_Blocking(&srl, "s", 1,0);
    srl_Write_Blocking (&srl, data, sizeof(data),0);
    srl_Write_Blocking(&srl, "e", 1,0);
     delay(100);
 }

I'm sure this code is very improper, but it works. The "s" and "e" are to indicate start and end of my data stream.

It looks like windows is closer to recognizing it as a valid serial device. Do I need to send something special over serial to get windows to realize that the device is started? Trying to open the serial port in my c# program fails. I tried uninstalling TI-Connect CE and the TI-84 Plus CE driver, but I still get the same error.
No, this is likely an issue with the library as well. I'm following the spec, but Microsoft obviously doesn't care about anything so trivial as international standards. I'll have to do some testing on Windows to try and figure out what exactly Windows doesn't like about it.

I'll for sure fix both the Windows issues and the crash when the buffer fills up prior to the actual release of the USB libs, which still seems to be a good ways off. It's a bit of a pain for me to test the library at this point, as I don't have a working copy of Windows, and I can't use CEmu to test USB things at this point.
Update, I was messing around with the library and was able to get rid of the errors in device manager
I'm using USB device tree viewer to get raw device descriptor information, and it looks like the descriptor class was set to 00 instead of 02. Changing it to 02 makes windows happy, but in c#, when trying to open the serial port, I get "A device attached to the system is not functioning."

Here is the updated descriptor line

Code:
.device emit $12: $1201000202000040510408F0200201020001 bswap $12
Quote:
I'm sure this code is very improper, but it works.

That sums up just about all code I write! I've just been hooking a USB port to the TX1/RX1 pins on my arduino mega (the TX0/RX0 pins are wired to it's USB B socket) and plugging the calc into that; I'll try scrounging for more ports or building some funky wire to connect the calc to the arduino. Also, don't use software serial for communication, it works well for slow speeds, but it's limited by the clock speed of the arduino, I2C would be better (and I have no clue why I guessed you were using pulse() commands, my brain must not have been turned on all the way). You could also just have the arduino flash an onboard light if it detects a serial connection. I'll see about messing with the descriptors myself, maybe I can break my calc even better this time!

I2C Tutorial on Arduino.cc

I also discovered something bizarre with the windows drivers: my PC couldn't open a serial port before using the original libraries, with the edited ones it worked, albeit with the error Code 10, but after reverting to the old libraries it could still open a COM port. I'll be testing on some other machines that don't have any of TI's drivers installed, and building a dedicated Linux machine for testing (and because I'm bored, but testing too). This may just be me, I'll try working with
Dmalenke's working code and some arduino witchcraft.
You can also just directly connect the TX pin of an Arduino to the TX pin of another serial device (or the RX pin of another Arduino) and vice versa and then tell the Arduino to quit using those pins. That bypasses the actual microcontroller and just connects the two USB UARTs together, and it requires no code.

I'm debugging the crash now, I'll see if I can get Windows working over the next few days.
Thanks for working on that commandblockguy
I didn't know you could do that with an arduino, I'll have to try that sometime

This is what I have so far and it seems to work with the arduino ide serial monitor which seems to ignore errors and force a serial monitor to open.

Code:

.device emit $12: $1201000202000040510408F0200201020001 bswap $12
.configurations dl .configuration1
.configuration1 emit $3e: $09023e00020100c0320904000000020200000524000110042402060524060001070582030800ff09040100020a0000000705040240000107058302400001 bswap $3e
 


The default serial echo program seems to work, but it looks like programs are struggling to work with the serial port because the calculator isn't handling parameter requests?
The arduino ide logs "Error while setting serial port parameters: 9,600 N 8 1"
I fixed a crash (I'd like to say the crash, but I have no idea if it's even the same issue) when using srl_Write. I forgot to check if bc was 0 before running an ldir, so if you exactly filled to the end of the circular buffer, the library would overwrite all of memory.

I'll check the Windows stuff later - hopefully I'll have it fixed by the end of the day tomorrow.

It really makes no sense to set serial port parameters on a virtual serial port like the one that srldrvce uses - it's not putting any bits on a physical line, so the baud rate is meaningless. I guess Windows requires that I handle that request, though - I'll probably just tell the host that I changed the parameters, but then just completely ignore them.
It seems like your fix removed the need to reinitialize serial every loop, but if nothing is reading from the serial buffer on the other side, we get an overflow again. Is there an easy way to check if there is an active serial consumer?
Another note, it looks like the errors in the arduino ide have disappeared, but I still am unable to access the serial port in c# with the same "A device attached to the system is not functioning" error. I believe it could still be related to the fact the calc is not handling requests though.
You definitely shouldn't be initializing every single loop - that re-requests all of the descriptors, which not only eats up bandwidth but also blocks program execution until finished.
I'm considering adding an equivalent for srl_Available but for writing. In the meantime, you can check what srl_Write returns to see if the write buffer is completely full.
I'm sure this is definitely not what you're supposed to do, but it works?
It's not throwing errors, but it's probably inefficient. (I don't know very much c)

Code:

if (event == USB_DEFAULT_SETUP_EVENT)
    {
        uint16_t *datas = &((uint16_t *)event_data)[sizeof(event_data)];

        for (size_t i = 0; i < sizeof(datas); i++)
        {
            char kb_Value[8] = "";
            sprintf(eventValue, "%d", datas[i]);
           // os_PutStrLine(eventValue);
           // os_NewLine();

            if ((int)eventValue== 7)
            {
                if (!*callback_data)
                {
                    /* Set the USB device */
                    *callback_data = event_data;
                }
            }
        }       
    }
  
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
Page 2 of 2
» All times are UTC - 5 Hours
 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

 

Advertisement