Read Input from TIC T249

Im not a coder, but I try to act like one sometimes. I want to read the inputs of RX and TX on my T249. Both are pulled up. I can pull one of the inputs down with a switch. Documentation says that I should be looking at 0x47. How do I look at JUST that?
I can see the status with “ticcmd --status -full” , but a bunch of additional data that I don’t want.

0x47 found here:

And other sections that “should” help me…but present no examples.

Hello.

I moved your post to our Motor controllers/drivers and motors category, which seemed more appropriate.

It sounds like you have configured the RX and TX pins of your Tic to be inputs and are trying to get digital readings from those inputs over USB. I recommend writing a program to run ticcmd --status --full, parse its output, and extract the information you are interested in. The output of that command uses the YAML format, and there are YAML parsers available for many different programming languages. For example, the Ruby language comes with a YAML parser built in, and here is an example Ruby program that gets the information you are looking for:

require 'open3'
require 'yaml'

def ticcmd(*args)
  command = 'ticcmd ' + args.join(' ')
  stdout, process_status = Open3.capture2(command)
  if !process_status.success?
    raise "Command failed with code #{process_status.exitstatus}: #{command}"
  end
  stdout
end

status = YAML.load(ticcmd('-s', '--full'))

tx_input = status.fetch('TX pin').fetch('Digital reading')
puts "TX: #{tx_input}"

rx_input = status.fetch('RX pin').fetch('Digital reading')
puts "RX: #{rx_input}"

If you don’t want to use a YAML parser, it shouldn’t be too hard to write a very simple parser to grab the information you are looking for. (Hint: start by splitting the output into lines, then process each line individually.)

I recommend looking at the “Writing PC software to control the Tic” section of the Tic user’s guide to see if there is some example code that is closer to what you are looking for. If you tell me what operating system and programming language you are using, I might be able to give advice more tailored to your situation.

–David

Hmm…I must be super old school. I know nothing about Ruby (Heard of it) or YAML. I’m using Windows 7 and 10. The only coding that I know is QBasic (QB64) and some DOS scripting.

I was hoping to use QB64 or a Batch file to read the inputs. Is there any hope?

Thanks in advance,
Thad

If there are any Ruby IDE as simplistic a QB64… I am all ears (or eyes). I learned C, but only use it for AVR programming. There seems to be no easy way to convert C code to a Windows EXE without organizing libraries…setting up a project folder…makefile…and probably 20 other steps required. I expect the same for Ruby.

Since QB64 and batch files are what you are familiar with, then I recommend trying to use those to run ticcmd and process its output. I am not very familiar with either, but I suspect that this task will be easier with QB64 than with a batch file.

The documentation of the SHELL command on the QB64 wiki has some example code (example #3) that shows how to run a program, save its output to a file, and then read the output into your program one line at a time. That would probably be a good place to start. Once you are able to read the first line of the output into your program, you could make a loop to read all the lines. Then it should be possible to add some code to process the lines and extract the information you need.

If you get stuck writing your program, you can post your code here, along with the details of what you are having trouble with, and I’ll see if I can help.

–David

UGG!! This is not working so well. Typing the command from the command prompt works exactly as expected. The results are dumped in a txt file.
Running it in QB64 does not.

The top 2 lines do NOT work
The bottom 2 lines do work.

SHELL _HIDE "ticcmd --status --full > temp.txt"
REM SHELL _HIDE "ticcmd --status --full" + " > temp.txt"

REM SHELL _HIDE "dir /b" + " > temp.txt"
REM SHELL _HIDE "CMD /C" + "wmic printer get name,default > temp.txt"

SHELL "start Notepad temp.txt" ' display temp file contents in Notepad window

Maybe posing it might shed some insight,

I downloaded QB64 and got the following code to work:

SHELL _HIDE "CMD /C ticcmd --status --full > temp.txt"

Note that this is different from your first line because it uses CMD /C.

At first, I had some trouble because there was a problem with how QB64 sets its PATH environment variable: it was using an old version of the PATH that did not include the location of the newly installed Tic software, so ticcmd was an unrecognized command. I solved that issue by restarting the computer.

If the code above does not work for you after restarting, please run the lines below to troubleshoot the issue, and let me know what you see:

SHELL "CMD /K echo %PATH%"
SHELL "CMD /K ticcmd --status --full > temp.txt"

–David