tc65 development catastrophy

Get help on programming - C++, Java, Delphi, etc.
Post Reply
thealluseless
Registered User
Posts: 614
Joined: 29 Dec 2006, 02:00
Location: somewhere in the blight

tc65 development catastrophy

Post by thealluseless »

here is my problem, i have programmed in c/c++ for awhile, so i have some experience. I have started java, which i have learnt pretty quickly.

the problem i have is i need to use java to programme a tc65 siemens module,i have both netbeans and eclipse, however i have no idea how to use either of these properly. I have one basic questions,

1. how do i include what in c would be a "header file", because i need to use a serious of "at" commands to control the unit. i have tried importing but not sure if this is right, since it still does not recongnise the code?

I have tried various websites but they seem to be of little use, and i have struggled to find reading material on this,

sorry if this seems basic but i have little experience with java or its associated programmes.
thealluseless
Registered User
Posts: 614
Joined: 29 Dec 2006, 02:00
Location: somewhere in the blight

Post by thealluseless »

ok no worries, have figured it out and yes i am an idiot. however i amsure i will be posting more, because this project is a nightmare.
thEnaileDonE
Registered User
Posts: 2200
Joined: 03 Jun 2006, 02:00

Post by thEnaileDonE »

Glad I could help ;)
If you are at your Wits End...
Image
Severed Fifth - Changing the way the music industry works, one song at a time!
thealluseless
Registered User
Posts: 614
Joined: 29 Dec 2006, 02:00
Location: somewhere in the blight

Post by thealluseless »

well maybe u can, how do u do multiple inheritance?

i have like

public class worksonofa*** extends midlet{
xxx
xxx
xxx
xx
}

but i also need it to have inherited ATCommand

public class worksoofa*** extends midlet,ATCommand{
***
}
type of thing???
Judas
Registered User
Posts: 2118
Joined: 17 Oct 2006, 02:00
Location: Stellenbosch
Contact:

Post by Judas »

Java doesn't support multiple inheritance, instead you should look at implementing Interfaces.
'One will rarely err if extreme actions be ascribed to vanity, ordinary actions to habit, and mean actions to fear.'
- Friedrich Nietzsche

'Do not argue with Judas, nube, that would be foolish!'
- D3PART3D
thealluseless
Registered User
Posts: 614
Joined: 29 Dec 2006, 02:00
Location: somewhere in the blight

Post by thealluseless »

Java doesn't support multiple inheritance, instead you should look at implementing Interfaces.
Ahhh,negative.

not sure what u mean? sorry but i started java yesterday
Judas
Registered User
Posts: 2118
Joined: 17 Oct 2006, 02:00
Location: Stellenbosch
Contact:

Post by Judas »

thealluseless wrote:
Java doesn't support multiple inheritance, instead you should look at implementing Interfaces.
Ahhh,negative.

not sure what u mean? sorry but i started java yesterday
Well, ATCommand is probably an interface, not a class, so you would implement it like this:

Code: Select all

public class WorkSonOfA*** extends Midlet implements ATCommand {
      // Class body goes here.
} 
I'd suggest you take a look The Java Tutorial, it's really very good and explains OOP nicely.
'One will rarely err if extreme actions be ascribed to vanity, ordinary actions to habit, and mean actions to fear.'
- Friedrich Nietzsche

'Do not argue with Judas, nube, that would be foolish!'
- D3PART3D
thealluseless
Registered User
Posts: 614
Joined: 29 Dec 2006, 02:00
Location: somewhere in the blight

Post by thealluseless »

hmm ok, its part of a class.zip file though, and i have to import it at top of my programme i think???

but will check out tutorial and hopefully have better understanding of what the hell i am doing,

thanks
Judas
Registered User
Posts: 2118
Joined: 17 Oct 2006, 02:00
Location: Stellenbosch
Contact:

Post by Judas »

thealluseless wrote:hmm ok, its part of a class.zip file though, and i have to import it at top of my programme i think???

but will check out tutorial and hopefully have better understanding of what the hell i am doing,

thanks
Yup, you'll need to unzip it and place the classes in the same directory as your .class files, or somewhere else in Java's CLASSPATH (environment variable which specifies where to look for .class files).

Once you've done that you can import it easily.

Code: Select all

import xxxxx.ATCommand;
'One will rarely err if extreme actions be ascribed to vanity, ordinary actions to habit, and mean actions to fear.'
- Friedrich Nietzsche

'Do not argue with Judas, nube, that would be foolish!'
- D3PART3D
thealluseless
Registered User
Posts: 614
Joined: 29 Dec 2006, 02:00
Location: somewhere in the blight

Post by thealluseless »

i think i am getting confused, because its part of this whole add-on siemens mobile pack, i can just import it normally, and it gives no errors?

but anyways, will check out this interface thing maybe its where i am going wrong.

One more question, i find this java thing funny because i dont need a main like in C,

it uses startapp and stuff like that? how exactly does it work?
Judas
Registered User
Posts: 2118
Joined: 17 Oct 2006, 02:00
Location: Stellenbosch
Contact:

Post by Judas »

Normal Java apps do need a main method, pretty similar to C:

Code: Select all

public static void main (String[] args) {
}
When dealing with Java EE/ME that doesn't apply though. Maybe you should get a feel for writing some normal Java applications before jumping into J2ME? Don't try to run before you can walk! ;)
'One will rarely err if extreme actions be ascribed to vanity, ordinary actions to habit, and mean actions to fear.'
- Friedrich Nietzsche

'Do not argue with Judas, nube, that would be foolish!'
- D3PART3D
thealluseless
Registered User
Posts: 614
Joined: 29 Dec 2006, 02:00
Location: somewhere in the blight

Post by thealluseless »

When dealing with Java EE/ME that doesn't apply though. Maybe you should get a feel for writing some normal Java applications before jumping into J2ME? Don't try to run before you can walk!
ha, would love to, unfortunately my company has thrown this on me and i now have a month to learn everything and finish the project.

Ho hum i love work.

The normal java apps arent too bad, it is not that dissimilar from c but i find it very "all over the place" for some reason. maybe just need get used to it
thealluseless
Registered User
Posts: 614
Joined: 29 Dec 2006, 02:00
Location: somewhere in the blight

Post by thealluseless »

ok, spent some time looking through tutorials and such. However i need a serious crash course in using Me. Any sites to help with this or books?

my problem is still the same, from what i can tell i have to use the extend MIDlet option ( i dont even know what that does which sucks), but i also need to use ATCommand, i dont think it is an interface since it gives me errors when i try to do this. (the errors are very unhelpfull).
User avatar
rustypup
Registered User
Posts: 8872
Joined: 13 Dec 2004, 02:00
Location: nullus pixius demonica
Contact:

Post by rustypup »

any question you can think of probably has multiple incarnations over at sun's mobility forums...

java's OOAD implementation is as clean as it gets while still being functional... i would strongly advise, as judas said, that you get to grips with the API before attempting to go mobile...

midlet applications do not provide access to a static execution entry point, (ala main()), for some fairly obvious security reasons... the native platform will be responsible for the start, pause, stop and dispose of each midlet. the programmer is required to provide the executable code within these methods, (MIDlet is abstract for this very reason...). note that this is true for midlets only....

based on the skechy info provided i would guess:
1) the javax.microedition package is not visible, either through class path, declaration or custom class loader..
2) (guessing), ATCommand is either as above or:
---> if interface, you will need to implement and provide the code for each method in the API
---> if abstract, you will need to extend and provide the code for each abstract method, (following the rules of single inheritance, you would first extend ATCommand, then create a second tier class extending MIDlet. this appraoch will require that you specifically cast back to ATCommand and is a shoddy attempt at multiple inheritance.. the interface approach is far neater...)
---> if neither, will require that you instantiate an object of that type.


i have no idea about the ATCommand package, so the above can, and should, be taken with NaCl...

what, exactly, is the compiler throwing out? compile time exceptions are rarely unhelpful...

.... lastly, which IDE are you using? - netbeans requires certain extensions be acquired for j2me devleopment... will also require that the wireless toolkit be installed...

<edit>
ATCommand API: <- requires that you instantiate the class.. a compile time error points to classpath issues...
</edit>
Most people would sooner die than think; in fact, they do so - Bertrand Russel
thealluseless
Registered User
Posts: 614
Joined: 29 Dec 2006, 02:00
Location: somewhere in the blight

Post by thealluseless »

i would strongly advise, as judas said, that you get to grips with the API before attempting to go mobile...
man how i would love too, but i dont have a choice, i gotta do this NOW.

dude just from what u have written there i have an idea that i have no idea what i am doing.

I am pretty sure the ATCommand is an interface, but why is it part of the class .zip files with all the other stuff like javax.microedition... ???

I have tried to use implement but i just get errors.

I am using ecplise with siemens sdk.

I think i am just gonna have try learning from bottom up at breakneck speeds, because i dont think this stabbing in the dark thing is gonna work out too well. I have read through the tutorials recommended by juda, and it is all pretty similar to C, but somewhere i am getting lost? any other places or books i can use to try get myself up to speed?

i have no idea about the ATCommand package, so the above can, and should, be taken with NaCl...
Ha forget about the salt, i am going straight to a pint of vodka.

btw thanks for help ppl.
User avatar
rustypup
Registered User
Posts: 8872
Joined: 13 Dec 2004, 02:00
Location: nullus pixius demonica
Contact:

Post by rustypup »

ok...

are you getting microedition related exceptions or is it balking over the siemens classes?... (post the error message)

the trick here is that the ME platform installed on the siemens phone is perfectly fine. your development machine, however, is not. you need to specify, either through the system classpath, the vm commad line or the IDE command line, where the package/s is/are located on your local machine in order to produce valid bytecode.

check the project properties for libs included in the compile/build options... if the siemens package isn't there, you will have issues...
Most people would sooner die than think; in fact, they do so - Bertrand Russel
thealluseless
Registered User
Posts: 614
Joined: 29 Dec 2006, 02:00
Location: somewhere in the blight

Post by thealluseless »

okie dokey, here is my simple programme, it is supposed to turn ports on the unit high and low, i have connected led's to them to see if they working.

I know the commands are right, becuase when i connect to the unit using hyper terminal they work,

package src;

import java.microedition.midlet.MIDlet;
import java.microedition.midlet.MidletChangeException;
import com.siemens.icm.io.ATCommand //is this right?????

public class printme extends MIDlet{

protected void startApp() throws MIDletStateChangeException{
ATCommand at=null;
at=new ATCommand; //this line gives error
at.send("at^scpio=1/r");
at.send("at^scpin=1,0,1,1/r");
System.out.println("are u working"?);
}
protected void pauseAPP{

}

protected void destroyApp(boolean arg0)throws MIDletStateChangeException{
}
}
error given is Syntax error on token ";",. expected
also tried to write it like ATCommand at=new ATCommand, same error
User avatar
rustypup
Registered User
Posts: 8872
Joined: 13 Dec 2004, 02:00
Location: nullus pixius demonica
Contact:

Post by rustypup »

thealluseless wrote: ATCommand at=null;
at=new ATCommand; //this line gives error
ha.
check the API <hyperlink>.... when declaring a new object in java, unlike c, the structure is..

Code: Select all

ATCommand at=new ATCommand(true);//request CSD support
//or
ATCommand at=new ATCommand(false);//exclude CSD support
java syntax requires the () in each instantiation call, (effectively, the call is a function returning a reference to a new entity of the declared type on the heap... unlike c/c++ you have no access to the actual pointer used. also, unlike ascii c, the call is not implicitly understood by the compiler.. most java compilers will not hunt down the most logical constructor to use when faced with new ATCommand;... the risk is :

Code: Select all

public MyClass(String someInit){
}
public MyClass(MyClass someInit){
}
if the constructor were fed a null, which of the above constructors is going to be used?...

on top of that is , aside from primitives, everything in java is an object... therefore :

Code: Select all

ATCommand at = ATCommand;//assumes that the 2nd ATCommand is a named reference to a previously instantiated object... (this would not be a legal declaration, btw...)
Most people would sooner die than think; in fact, they do so - Bertrand Russel
thealluseless
Registered User
Posts: 614
Joined: 29 Dec 2006, 02:00
Location: somewhere in the blight

Post by thealluseless »

java syntax requires the () in each instantiation call, (effectively, the call is a function returning a reference to a new entity of the declared type on the heap... unlike c/c++ you have no access to the actual pointer used. also, unlike ascii c, the call is not implicitly understood by the compiler..
Stupid java advanced sytax

Thanks will give it a try
User avatar
rustypup
Registered User
Posts: 8872
Joined: 13 Dec 2004, 02:00
Location: nullus pixius demonica
Contact:

Post by rustypup »

:lol:

actually, the drive behind the language was to reduce development time as well as bugs.. by enforcing the above standard, they are reducing the possibility of having the programmer create NPE exceptions through malformed syntax.. it may seem a longwinded approach, (and sometimes it is), but the reailty is that those two keystrokes save an immense amount of heartache :wink:
Most people would sooner die than think; in fact, they do so - Bertrand Russel
thealluseless
Registered User
Posts: 614
Joined: 29 Dec 2006, 02:00
Location: somewhere in the blight

Post by thealluseless »

ATCommand at=new ATCommand(true);//
at.send("at^scpio=1/r");
at.send("at^scpin=1,0,1,1/r");

ok now i get multiple markers error on the first line.????
and unhandled exception type ATCommandFailedException on all the lines.
I kinda understand the second error (just got that chapter in textbook) but how do i fix it
User avatar
rustypup
Registered User
Posts: 8872
Joined: 13 Dec 2004, 02:00
Location: nullus pixius demonica
Contact:

Post by rustypup »

thealluseless wrote:and unhandled exception type ATCommandFailedException on all the lines.
you're not trying...

Code: Select all

try{
 ATCommand at = new ATCommand(false);
}
catch(IllegalStateException ise){
 //handle error
}
catch(ATCommandFailedException atcfe){
 //handle error
}
or...

Code: Select all

private ATCommand com;
public MyClass() throws IllegalStateException, ATCommandFailedException {
   com = new ATCommand(false);
}
the first example is debatable and could appear within any function, the second requires that the class caller handle the exceptions... personal choice...

again, the option of handling the exception locally or not is electable, so you may choose to manage the "command failed" instance in this class, and "pass" to state exception on to a global controller... or vice versa...

be aware that most bugs in the java language occur through lazy consumption of exceptions.. .(empty catch blocks that do nothing with the exception... at the very least, log it... )
Most people would sooner die than think; in fact, they do so - Bertrand Russel
Judas
Registered User
Posts: 2118
Joined: 17 Oct 2006, 02:00
Location: Stellenbosch
Contact:

Post by Judas »

rustypup wrote:be aware that most bugs in the java language occur through lazy consumption of exceptions.. .(empty catch blocks that do nothing with the exception... at the very least, log it... )
I couldn't agree more. You'll waste a lot of time hunting down bugs if you're not handling exceptions properly, trust me. At the very least you should do this, so that the stack trace gets printed to the standard output:

Code: Select all

try {
  // Code
} catch (IllegalStateException ex) {
  ex.printStackTrace(); // Print the stack trace to stdout.
}
I just came across http://www.microjava.com, it looks quite informative, with a wide variety of articles - maybe you can find something useful there.
'One will rarely err if extreme actions be ascribed to vanity, ordinary actions to habit, and mean actions to fear.'
- Friedrich Nietzsche

'Do not argue with Judas, nube, that would be foolish!'
- D3PART3D
Gds
Registered User
Posts: 1
Joined: 16 Jan 2007, 02:00

Post by Gds »

Thealluseless has quit this project and recommended me to come here for help...

Now me stuck with hectic job...


HELP! HELP! HELP!


ok so here's the thing!

the following program works... you can send the TC65 information via Hyper terminal and it will echo it back to you!

But now me gotta get the program to look for a Start Of Header... SOH.. ascii value... then check for "," comma and the next value says how much information is gonna be sent then after info is sent a End Of Transmission code comes through. ascii code.. dec value of 004.

how do i change the code to desipher it?

here's the working code...


protected void startApp() throws MIDletStateChangeException
{
super.startApp();
// Get the serial connection
SerialConnection connection = SerialManager.getSerialConnection("COM0");
// Connect the serial port
connection.connect();
// Write "Hello World !"
try
{
connection.getOutputStream().write("Hello World !\r\n".getBytes());
byte[] dataRead = new byte[10];
while(true)
{
int read = connection.getInputStream().read (dataRead);
connection.getOutputStream().write(dataRead,0,read);
}
}
catch (IOException e)
{
// Error... ending sample
connection.disconnect();
}
}


Any help will be appreciated!!!!

Thanks!
Post Reply