Notification

Icon
Error

Initiating Serial Connection with a Game
Callil
#1 Posted : Wednesday, April 11, 2012 4:01:44 PM(UTC)
Rank: Tinkerer

Joined: 4/9/2012(UTC)
Posts: 2

I've been working on a project to hack and communicate with a Gameboy Printer using Microsofts .NET gadgeteer modules. Up until now I was dealing with hardware (see this thread:http://www.tinyclr.com/forum/21/6665/)


I've wired the printer up as an SPI serial connection as required, and now I need to start swapping byte packages with the printer to start exploring printing.


I've made an attempt to put some code together but I've failed miserably. I can't really figure out how to speak to the printer. The only progress I've made is the SPI config, but the actual communication is beyond what I can understand. Perhaps someone can't point me in the right direction?


Here is the code I am trying to replicate: http://milesburton.com/i...r_Arduino_Alpha_0.01.pde

My main references are Thermaldotnet (a lib for the sparkfun printer) https://github.com/yukimizake/ThermalDotNet

SPI on Spider: http://tinyclr.com/forum/21/6621/

and a basic SPI example: http://wiki.tinyclr.com/...?title=SPI_-_MP3_Decoder



using System;
using System.Collections;
using System.Threading;
using Microsoft.SPOT;
using Microsoft.SPOT.Presentation;
using Microsoft.SPOT.Presentation.Controls;
using Microsoft.SPOT.Presentation.Media;
using Microsoft.SPOT.Touch;
using Microsoft.SPOT.Hardware;
 
using Gadgeteer.Networking;
using GT = Gadgeteer;
using GTM = Gadgeteer.Modules;
using Gadgeteer.Modules.GHIElectronics;
 
namespace printTherm
{
public partial class Program
{
static SPI MySPI = null;
public static void Sub()
{
 
InputPort Therm;
Therm = new InputPort(Cpu.Pin.GPIO_Pin8, false, Port.ResistorMode.PullUp);
 
SPI.Configuration MyConfig =
new SPI.Configuration(Cpu.Pin.GPIO_Pin8,
false, 0, 0, true, true, 1000, SPI.SPI_module.SPI1);
MySPI = new SPI(MyConfig);
 
 
 
bool exit = false;
do
{
byte[] tx_data = new byte[1];
byte[] rx_data = new byte[0];
while (Therm.Read() == true) ;
 
tx_data[0] = 0x01;
tx_data[1] = 0x00;
 
MySPI.WriteRead(tx_data, rx_data);
 
while (Therm.Read() == false) ;
byte[] tx_data2 = new byte[28];
byte[] rx_data2 = new byte[28];
for (int i = 0; i < 28; i++)
{
tx_data2[i] = 0xFF;
rx_data2[i] = 0x00;
}
MySPI.WriteRead(tx_data2, rx_data2);
} while (exit == false);
 
 
Thread.Sleep(100);
}
 
// This method is run when the mainboard is powered up or reset.
void ProgramStarted()
{
 
Debug.Print("Program Started");
}
}
}
 
 




It's almost exactly the same as the code above, except I've change the Pin to 8 (MISO) and added some array stuff. I'm really just going blind at this point. I feel bad coming into this with such poor knowledge, but any little help would be greatly appreciated.

some more resources for anyone interested in this:
full music shield code: http://code.tinyclr.com/...ct/330/fez-music-shield/

Rss Feed  Atom Feed
Users browsing this topic
Guest
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

Powered by YAF | YAF © 2003-2011, Yet Another Forum.NET
This page was generated in 0.098 seconds.