PINK V2 object for spin stamp
Peter Verkaik
Posts: 3,956
I converted my PinkV2 javelin class to a spin object.
Both are attached so they can be compared. The spin object compiles without error.
I have a few questions:
Is it possible to pass a FullDuplexSerial object to the PinkV2 object?
Right now, I pass the tx pin and rx pin but I rather define the uart
in my main program.
The methods writeVarBuf and readVarBuf have a parameter buf.
This is supposed to be a byte array holding a null terminated string.
I hardcoded the length of this buffer to 64 bytes, but is it possible
to extract the bufferlength from the parameter itself (eg. buf.length)
or must I pass the length using an additional parameter?
In java, method overloading allows me to use the same method name
with different parameter lists. The method writeVarString does the same
as writeVarBuf, except it has a string as parameter.
Does this at all apply to spin, or is a string in spin just a byte array?
(in which case writeVarString can be omitted)
Is it possible to define public and private constants?
The public constants would be used to address the special pink registers by name.
regards peter
Post Edited (Peter Verkaik) : 12/11/2007 4:26:44 AM GMT
Both are attached so they can be compared. The spin object compiles without error.
I have a few questions:
Is it possible to pass a FullDuplexSerial object to the PinkV2 object?
Right now, I pass the tx pin and rx pin but I rather define the uart
in my main program.
The methods writeVarBuf and readVarBuf have a parameter buf.
This is supposed to be a byte array holding a null terminated string.
I hardcoded the length of this buffer to 64 bytes, but is it possible
to extract the bufferlength from the parameter itself (eg. buf.length)
or must I pass the length using an additional parameter?
In java, method overloading allows me to use the same method name
with different parameter lists. The method writeVarString does the same
as writeVarBuf, except it has a string as parameter.
Does this at all apply to spin, or is a string in spin just a byte array?
(in which case writeVarString can be omitted)
Is it possible to define public and private constants?
The public constants would be used to address the special pink registers by name.
regards peter
Post Edited (Peter Verkaik) : 12/11/2007 4:26:44 AM GMT
Comments
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
"A complex design is the sign of an inferior designer." - Jamie Hyneman, Myth Buster
DGSwaner
It compiles but some things need to be addressed.
I defined two methods debug and printf that output a string and formatted string
to a serial outpin. Since my testprogram is intended for the Spin stamp
I would like to use the SOUT pin. What pin number is SOUT?
I copied the Pink constants to the main program. Is there a way to reference
these constants (defined in PinkV2 object) directly other than copying
from the object.
Also, can anyone answer the questions in my previous post?
regards peter
Is it possible to pass a FullDuplexSerial object to the PinkV2 object?
- You cannot pass objects via pointers or anything of the sort. You can use SerialMirror, which is a FullDuplexSerial implementation that allows sharing of a serial port across multiple objects. You can get this object from the object exchange.
must I pass the length using an additional parameter?
- The array concept is not like the one provided in Java. There is no .length operator since arrays in SPIN are just a group of consecutive memory locations. You will have to use a constant define or pass lengths for array bounding. If your array is guaranteed to be a zero terminated string than you can use strsize() to obtain the current length of the string contained in the array.
In java, method overloading allows me to use the same method name with different parameter lists. .... Does this at all apply to spin, or is a string in spin just a byte array?
- You cannot use method/function overloading in SPIN. The compiler will give you an error such as 'symbol already defined'. You will have to have different function names. Also, a string is just a byte array that is zero-terminated. You will be passing pointers to strings.
Is it possible to define public and private constants?
All constants are private to the specific object/source file. They can be externally accessed by myObj#myConstant.
Is there a way to reference these constants (defined in PinkV2 object) directly other than copying from the object.
You access constants by using myObj#myConstant.
Harrison
Post Edited (Harrison.) : 12/11/2007 6:30:11 AM GMT
How do I reference spin stamp pins SIN and SOUT? I have read in this thread
http://forums.parallax.com/showthread.php?p=671535
that SOUT may or may not work. I would like to test this for myself.
regards peter
I added pin definitions for SOUT, SIN and ATN of the spin stamp.
Also completed the debugOut method.
Edit: since strings are just null terminated byte arrays,
I removed the writeVarString method and renamed writeVarBuf and readVarBuf
to writeVar and readVar.
regards peter
Post Edited (Peter Verkaik) : 12/11/2007 2:01:25 PM GMT
Used buf[noparse][[/noparse]h] where I should have used byte[noparse][[/noparse]buf+h] to access bytes.
Also used >= instead of =>
regards peter
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
"A complex design is the sign of an inferior designer." - Jamie Hyneman, Myth Buster
DGSwaner
I won't be able to hook it up to the spin stamp
until I got my new board (with fixed Pink connector) assembled.
That won't be sooner than next week, awaiting parts.
regards peter
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
"A complex design is the sign of an inferior designer." - Jamie Hyneman, Myth Buster
DGSwaner
On the picture it is the 2x5 pinheader that connects directly to
the Pink 2x5 header using a flatcable.
You only need the connections TX,RX,GND,5V as in the documentation.
regards peter
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
"A complex design is the sign of an inferior designer." - Jamie Hyneman, Myth Buster
DGSwaner
regards peter
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
"A complex design is the sign of an inferior designer." - Jamie Hyneman, Myth Buster
DGSwaner
As the picture shows, the code works for me.
regards peter
your multicogdebug object references a format object, is that the format object from the object exchange? that's what I've been using. Am I missing some thing? I'm connecting the TX/RX lines directly to the propeller i/o pins on the propeller. What am I doing wrong?
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
"A complex design is the sign of an inferior designer." - Jamie Hyneman, Myth Buster
DGSwaner
You then must get readable text using 9600 baud, 8 databits, no parity.
I do so.
If you do not use a spin stamp, change the clocksettings appropiate.
Propeller demoboard
· _clkmode = xtal1+pll16x
· _xinfreq = 5_000_000
Because debugPort is set to 1, the monitor ATN pin (in seperate cog) is not started.
(I only included it to be able to reset the spin stamp via the ATN pin).
Lets tackle this step by step. First you must get readable output.
regards peter
I attached them here also for convenience.
regards peter
with the TX and RX pin of the pink. That's how I connected the pink
to pins A10 (via 1k to pink TX) and A11 (via 1k to pink RX).
Also note that the pink requires 250mA+ current. I have a seperate
power supply for the pink.
regards peter
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
"A complex design is the sign of an inferior designer." - Jamie Hyneman, Myth Buster
DGSwaner
Thanks this is a huge mile stone.
I added some 1k resistors! it did work with out them... but I know it's tempting Merphys law
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
"A complex design is the sign of an inferior designer." - Jamie Hyneman, Myth Buster
DGSwaner
Post Edited (Dgswaner) : 12/21/2007 2:53:31 AM GMT