Omnimaga

Calculator Community => Other Calculators => Topic started by: LincolnB on July 20, 2011, 07:45:00 pm

Title: Two Questions
Post by: LincolnB on July 20, 2011, 07:45:00 pm
I have two questions, aptly-stated by the title of this thread. My first question is about using the global CALCnet client program I downloaded from Cemetech.net http://www.cemetech.net/programs/index.php?mode=file&path=/win/gcnclient.zip. Reading through the included readme-style PDF document, I understood basically how it works. 

I’m trying to connect my calculator to the internet using Gossamer and the gCn Client software. To get to this work, the way I understand it, I need to run the gcnclient.exe program with some command line arguments.
What exactly are the arguments that I would need to type in the command prompt to get it to work? So far what I have is :
Code: [Select]
>gcnclient.exe -n WebHub
-l (don’t know what to put here)
-s (no idea)
-p 4295
-d direct (not sure if this works yet)

(Obviously without the carriage returns)
So yeah. That’s what I would like cleared up about that.

My second question is, how do I make use of interrupts in Axe? What is some example code where interrupts would be useful? I kind of understand what interrupts are, but not completely.

Thanks.
Title: Re: Two Questions
Post by: Binder News on July 20, 2011, 07:49:33 pm
Interrupts are triggered by hardware every ____(you can set the frequency) of a second. When interrupts occur, the CPU switches from executing code where ever it is currently executing to where the interrupt code is. A good usage would be as a timer, as it is called at consistent times, regardless of how much code is executed around it.
Title: Re: Two Questions
Post by: Ashbad on July 20, 2011, 07:50:20 pm
Interrupts are basically events that are triggered every few assembly instructions, at a call frequency defined by the second argument of fnInt(.  The first gives the subroutine to be called every few cycles, the second is the speed.  Example:

Code: [Select]
fnInt(LOL,0)

Lbl LOL
  Disp "LOL"
Return

The word "LOL" will be displayed every few cycles.
Title: Re: Two Questions
Post by: LincolnB on July 20, 2011, 07:52:50 pm
So if I did:

Code: [Select]
fnInt(LOL,5)
then the code at Lbl LOL will be executed five times every second, or every 5 assembly instructions?
Title: Re: Two Questions
Post by: Binder News on July 20, 2011, 07:57:18 pm
It's not 5 times a second. It might be every 5 instructions. Maybe it's every 5 CPU cycles. I can't remember off the top of my head.
Title: Re: Two Questions
Post by: LincolnB on July 20, 2011, 08:00:23 pm
About what does the frequency have to be if you want some code to execute once every second?
Title: Re: Two Questions
Post by: Darl181 on July 20, 2011, 08:00:33 pm
Quote from: commands list
FnInt(LBL,FREQ) Turns the subroutine into an interrupt and then turns interrupts on. The frequency can be (fastest) 0, 2, 4, or 6 (slowest). L2 is used for interrupt data so do not use L2 for storage when using interrupts.
http://eeezor.ec3club.tk/Files/Resources/program%20readmes/Axe/Commands.htm#Int

Seems to me the same thing Desolate has? :P
Title: Re: Two Questions
Post by: Runer112 on July 20, 2011, 08:03:25 pm
Although you can specify whatever number you want for the second argument, fnInt()'s second argument is always ANDed with 6. This means that the only meaningful second argument values are 0, 2, 4, and 6. The interrupts will then run at a frequency according to the chart below:

Freq argument   83+BE Freq   All Else Freq
0560Hz512Hz
2248Hz227.55Hz
4170Hz146.29Hz
6118Hz107.79Hz
Title: Re: Two Questions
Post by: LincolnB on July 20, 2011, 08:04:58 pm
Do you know how I might set up an interrupt to do something once every second?
Title: Re: Two Questions
Post by: Binder News on July 20, 2011, 08:07:01 pm
You would need a counter. Then, set it to 0, and when an interrupt is called, increment the counter. If the counter equals a certain value, then reset it and execute the code.
Title: Re: Two Questions
Post by: ben_g on July 20, 2011, 08:07:14 pm
count the number of calls. When the interupt routine has been called 118 times at frequence 6 on a 83+, then do something

Example:
Code: [Select]
.timer
0->A
0->B
fnInt(INT,0)
Repeat GetKey(15)
End
lnReg

lbl INT
A+1->A
Return!If A=512
B+1->B
Disp B
0->A
Return
Title: Re: Two Questions
Post by: Runer112 on July 20, 2011, 08:15:04 pm
The DS<( command can be useful for running an interrupt at a low frequency. On non-83+BE calcs, enclosing all the code in a subroutine running on a 512Hz interrupt with DS<(I,512) can be used to execute a block of code exactly once per second:

Code: [Select]
512→I
fnInt(I,0)

.Main program goes here

Lbl I
  DS<(I,512)
    .1Hz interrupt code goes here
  End
Return


However, on the 83+BE, the timers aren't exact, so don't expect to be able to pull off perfect timing on it. If you're not using the timer for precise timing, you can use the following code. This solution should create an ~1Hz interrupt on any model:

Code: [Select]
fnInt(I,6→I)

.Main program goes here

Lbl I
  DS<(I,{Full+1+Data(108,118)})
    .1Hz interrupt code goes here
  End
Return
Title: Re: Two Questions
Post by: LincolnB on July 21, 2011, 04:48:54 pm
Thanks for the help, this is pretty awesome information.

Can anyone answer my gCn client question?
Title: Re: Two Questions
Post by: JosJuice on July 22, 2011, 03:47:44 am
Can anyone answer my gCn client question?
Maybe you could try asking on Cemetech? They know a lot about gCn.
Title: Re: Two Questions
Post by: calcdude84se on July 22, 2011, 10:45:37 am
Quote from: calcdude84se
If you're on Windows, you'll also need to install the filter driver. Get libusb-win32 at http://sourceforge.net/projects/libusb-win32/files/libusb-win32-releases/1.2.4.0/libusb-win32-bin-1.2.4.0.zip/download (http://sourceforge.net/projects/libusb-win32/files/libusb-win32-releases/1.2.4.0/libusb-win32-bin-1.2.4.0.zip/download), extract the .zip file, and run bin\x86\install-filter-win.exe
Quote from: calcdude84se
... <local_name> can be anything, but is often based on user name (I use "CalcHub", for example. The main idea is that you provide something unique.) You can ignore the -s and -p options almost always; they default to what's necessary to connect to the server Kerm's set up.
(To clarify: <local_name> refers to what's after -l.)
To use DirectUSB, you are correct in using "-d direct", but note that "-d d" also works and is shorter ;)
Title: Re: Two Questions
Post by: LincolnB on July 22, 2011, 11:48:44 am
Thanks, I'll try that out as soon as I get on my primary computer.