With CALCNet becoming so accessible to the less able programmer in the form of DCSB libs, I was pondering how easy it is to create a computer-side program for use with CALCNet? I am aware that the gCn client works with "bridges," and was wondering how I could actually go about making one for my own programs. I'm sure this information would be a lot of use to others too.
Ask and you shall receive! I have published an example bridge for globalCALCnet that includes almost everything you need. It connects to the metahub, identifies itself as a fake calculator, and begin accepting incoming messages. It also includes code to send messages out again, and has a logging library and an ASCII-to-calculator encoding conversion library. All you need to do is fill in the hub name and the application logic.
http://www.cemetech.net/programs/index.php?mode=file&id=909
http://www.cemetech.net/programs/index.php?mode=file&id=909
Quick question, do you connect your calculator to the computer-side program using the global CALCnet client or do you use the bridge program?
Check out my BitBucket!
Projects In Progress:
WAti - WolframAlpha for TI-83+/84+ calculators
[img]http://www.cemetech.net/img/sigs/forumsig.php?uid=3503[/img]
Projects In Progress:
WAti - WolframAlpha for TI-83+/84+ calculators
[img]http://www.cemetech.net/img/sigs/forumsig.php?uid=3503[/img]
ElectronicsGeek wrote:
Quick question, do you connect your calculator to the computer-side program using the global CALCnet client or do you use the bridge program?
The bridge program connects to gcnhub.cemetech.net and pretends to be a calculator. gcnclients also connect to the gCn hub with their own (real) calculators, and the bridge you create communicates with those calculators. The gCnClient program connects real calculators to globalCALCnet, and any gCn bridge you create (including Python ones) connects directly to the hub.
I'm finding the bridge extremely useful so far, thank you very much Kerm.
Quick question:
How can I turn the data from the calculator into readable ASCII text.
I have tried this:
Code:
However, it fails to create the desired result. Any ideas?
Quick question:
How can I turn the data from the calculator into readable ASCII text.
I have tried this:
Code:
cleanstr(thismsg)[:14]
However, it fails to create the desired result. Any ideas?
Check out my BitBucket!
Projects In Progress:
WAti - WolframAlpha for TI-83+/84+ calculators
[img]http://www.cemetech.net/img/sigs/forumsig.php?uid=3503[/img]
Projects In Progress:
WAti - WolframAlpha for TI-83+/84+ calculators
[img]http://www.cemetech.net/img/sigs/forumsig.php?uid=3503[/img]
That's not what cleanstr() is for. Take a look at the encode/decode convenience functions and see if they help at all. You'll probably want to use cleanstr() in conjunction with those.
Apparently calcdecode is not defined. Any reason why?
Check out my BitBucket!
Projects In Progress:
WAti - WolframAlpha for TI-83+/84+ calculators
[img]http://www.cemetech.net/img/sigs/forumsig.php?uid=3503[/img]
Projects In Progress:
WAti - WolframAlpha for TI-83+/84+ calculators
[img]http://www.cemetech.net/img/sigs/forumsig.php?uid=3503[/img]
ElectronicsGeek wrote:
Apparently calcdecode is not defined. Any reason why?
Did you include the module for it properly? I can give you specific code for that when I get home later.
Kerm, have you sorted the code yet?
Thanks.
Thanks.
Check out my BitBucket!
Projects In Progress:
WAti - WolframAlpha for TI-83+/84+ calculators
[img]http://www.cemetech.net/img/sigs/forumsig.php?uid=3503[/img]
Projects In Progress:
WAti - WolframAlpha for TI-83+/84+ calculators
[img]http://www.cemetech.net/img/sigs/forumsig.php?uid=3503[/img]
I think I used:
Code:
But it said it wasn't defined.
Code:
import calcencoder
But it said it wasn't defined.
Check out my BitBucket!
Projects In Progress:
WAti - WolframAlpha for TI-83+/84+ calculators
[img]http://www.cemetech.net/img/sigs/forumsig.php?uid=3503[/img]
Projects In Progress:
WAti - WolframAlpha for TI-83+/84+ calculators
[img]http://www.cemetech.net/img/sigs/forumsig.php?uid=3503[/img]
You'd need something like:
Code:
If that doesn't work:
1) Make sure you're running your bridge from the same directory as calcencoder.py
2) You might need to add an __init__() method to the CalcEncoder class and instantiate it first.
Code:
from calcencoder import CalcEncoder
# ...
CalcEncoder.calcencode(stuff)
# ...
CalcEncoder.calcdecode(stuff)
If that doesn't work:
1) Make sure you're running your bridge from the same directory as calcencoder.py
2) You might need to add an __init__() method to the CalcEncoder class and instantiate it first.
Ah, I see. Thank you very much Kerm.
Check out my BitBucket!
Projects In Progress:
WAti - WolframAlpha for TI-83+/84+ calculators
[img]http://www.cemetech.net/img/sigs/forumsig.php?uid=3503[/img]
Projects In Progress:
WAti - WolframAlpha for TI-83+/84+ calculators
[img]http://www.cemetech.net/img/sigs/forumsig.php?uid=3503[/img]
I'm having a few problems with the import.
The Error
Code:
CalcEncoder's Code:
Code:
Finally the import in my version of the gCn skeleton:
Code:
Apologies for the massive post...
The Error
Code:
Traceback (most recent call last):
File "gcnskel.py", line 11, in <module>
from calcencoder import CalcEncoder
ImportError: cannot import name CalcEncoder
------------------
(program exited with code: 1)
Press return to continue
CalcEncoder's Code:
Code:
def __init__(self):
class CalcEncoder:
# ....stuff.....
# Encode ASCII into calculator-formatted strings
def calcencode(self,input):
#stuff....
# Decode calculator-formatted strings into ASCII
def calcdecode(self,input):
#stuff....
Finally the import in my version of the gCn skeleton:
Code:
from calcencoder import CalcEncoder
Apologies for the massive post...
Check out my BitBucket!
Projects In Progress:
WAti - WolframAlpha for TI-83+/84+ calculators
[img]http://www.cemetech.net/img/sigs/forumsig.php?uid=3503[/img]
Projects In Progress:
WAti - WolframAlpha for TI-83+/84+ calculators
[img]http://www.cemetech.net/img/sigs/forumsig.php?uid=3503[/img]
The CalcEncoder class's code should look something like this:
Code:
Don't copy-paste this, though, as I used spaces instead of tabs.
Code:
class CalcEncoder:
# all the constants like x2t and t2x...
def __init__(self):
pass
def calcencode(self,input):
#stuff
def calcdecode(self,input):
#stuff
Slight necropost here, but I have a question regarding gcnskel.py .
My question regards the function outtoclient:
Code:
I was generally wondering how one goes about using this function, such as how one might call it and what I should put as the parameters.
Thanks a lot
My question regards the function outtoclient:
Code:
def outtoclient(type,seq,contents,sid):
gcnlock.acquire()
msgindex = 0;
thisoutmsg = chr(type) + chr(seq) + contents
outmsghdr = chr(0xAA)+chr(0xAA)+chr(0xAA)+chr(0xAA)+chr(0xAA)+\
chr(len(thisoutmsg)&0x00ff)+chr((len(thisoutmsg)>>8)&0x00ff)
outmsghdr = outmsghdr + thisoutmsg
log_info("Forwarding '"+outmsghdr+"' to '"+calc5to10(sid)+"'")
thismsg = chr(255)+chr(137)+sid+outmsghdr+chr(42)
thismsg = chr(len(thismsg)&0x00ff)+chr((len(thismsg)>>8)&0x00ff)+\
'f'+thismsg
clientsocket.sendall(thismsg)
gcnlock.release()
I was generally wondering how one goes about using this function, such as how one might call it and what I should put as the parameters.
Thanks a lot
Check out my BitBucket!
Projects In Progress:
WAti - WolframAlpha for TI-83+/84+ calculators
[img]http://www.cemetech.net/img/sigs/forumsig.php?uid=3503[/img]
Projects In Progress:
WAti - WolframAlpha for TI-83+/84+ calculators
[img]http://www.cemetech.net/img/sigs/forumsig.php?uid=3503[/img]
Code:
def outtoclient(type,seq,contents,sid):
So in essence, type and seq can be any byte and sid is the calculator's ID when it joins gCn?
Check out my BitBucket!
Projects In Progress:
WAti - WolframAlpha for TI-83+/84+ calculators
[img]http://www.cemetech.net/img/sigs/forumsig.php?uid=3503[/img]
Projects In Progress:
WAti - WolframAlpha for TI-83+/84+ calculators
[img]http://www.cemetech.net/img/sigs/forumsig.php?uid=3503[/img]
ElectronicsGeek wrote:
So in essence, type and seq can be any byte and sid is the calculator's ID when it joins gCn?
That is correct. You will also get an SID from a calculator sending a request to your bridge, of course.
Having a slight problem with data transmission. Would you say my computer side code is off or is it the calc side code?
Calc Side:
Code:
Computer Side:
Code:
This combination is returning BASIC Ex Err:UND (Code 519).
Cheers.
Calc Side:
Code:
sum(19,1
sum(18
Disp Str9
sum(19,0
Computer Side:
Code:
outtoclient(0x44,0x44,"Hello World",calc5)
This combination is returning BASIC Ex Err:UND (Code 519).
Cheers.
Check out my BitBucket!
Projects In Progress:
WAti - WolframAlpha for TI-83+/84+ calculators
[img]http://www.cemetech.net/img/sigs/forumsig.php?uid=3503[/img]
Projects In Progress:
WAti - WolframAlpha for TI-83+/84+ calculators
[img]http://www.cemetech.net/img/sigs/forumsig.php?uid=3503[/img]
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
» Go to Registration page
» Goto page 1, 2 Next
» View previous topic :: View next topic
» View previous topic :: View next topic
Page 1 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
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