It receives data via RS232, so I'm using serial library with Serial-RS232 cable.
I send data to the printer repeatedly, and I need to pause sending when XOFF is sent from the printer, and resume when I get XON.
A technician of the manufacturer said that the printer sends XOFF when it has its buffer full, but I cannot read anything via
serialEvent() until I see some weird errors printing out.
In any other situations, I can receive data from printer well, including XON right after initiating the printer and status code when I ask one.
I'm making an android app but having some bad problems.
I found that using 'get' crashes the application.
Since copying a part of the screen is the essential part of the app, I need to get it done but don't know how.
Is there any solution or workaround to do this?
Here is my code.
Original code is much much longer and contains a lot of functions that does not matter in this topic, so I quick-wrote an alternative code to demonstrate the failure caused by using 'get' and to show you the basic function of the drawer app.
int pX = 0;
int pY = 0;
boolean firstTouch = true;
PImage a;
void setup() {
orientation(PORTRAIT);
background(255);
a = new PImage(300, 400, ARGB);
}
void draw() {
a = get(0, 0, 300, 400);
image(a, 300, 0);
}
void mouseDragged() {
stroke(0);
strokeWeight(10);
line(pX, pY, mouseX, mouseY);
pX = mouseX;
pY = mouseY;
}
void mousePressed() {
if(firstTouch) {
pX = mouseX;
pY = mouseY;
firstTouch = false;
}
}
void mouseReleased() {
firstTouch = true;
}
So the code is basically a drawer, but the function I need so bad is to copy certain part of the screen and make it to a PImage variable.
The code crashes immediately after launching, but if you delete the 'get' part, it works just fine.
For days, I've been trying to make a not-that-very-simple game.
I started with making some basic interfaces and positioning them without actual function.
It had been so far so good until I noticed that the program takes too much memory, over 600MB often.
To compare, I played Braid, which never exceeded 300MB of memory all the time.
Originally, I coded the program to load up all data at the beginning and never throw them away.
Since I thought this had been a problem, I modified the program to load and throw away data according to the in-game phase.
Say, there are two phases for the game: MENU and WORLD.
In modified code, all needed data for MENU are loaded just before executing MENU.
If you wish to go to WORLD phase, data for MENU are nullified and data for WORLD are loaded before executing WORLD.
Changing phase from WORLD to MENU makes the same process in reverse.
However, it seems like that nullifying variables and objects is never working in terms of memory problem.
The memory never be freed up, while loading data always increases memory usage.
What this means is that if you repeat to go to MENU and WORLD on and on, memory usage just soars, which make the program crash or the whole system restart in the end.
I googled the problem and found that there's something called garbage collector.
I tried to manually call it("System.gc()") knowing that it is not a good idea for most times.
Frustratingly, this didn't seem to work also.
I wonder what is the problem and how can I fix this.
I just cannot concentrate on making the game further because without having the problem solved, doing more would only worsen the problem.
Note that I'm not familiar with any other language including native java, and never have dealt with memory problem so far, which means I'm nearly ignorant about these memory things.
The entire code can be downloaded through the link below: