import java.io.IOException;
import java.io.InputStream;

public class SerialReader implements Runnable{
	
	InputStream in;
	
	public static String Data = "";
	
	WebInPut client = null;
	
	public SerialReader(InputStream in, WebInPut _client) {
		
		this.in = in;
		this.client = _client;
	}
	
	public void run() {
		
		byte[] buffer = new byte[1024];
		
		int len = -1;
		
		try {
			
			while ((len = this.in.read(buffer)) > -1) {
				
				System.out.print(new String(buffer, 0, len));
				String iaa = new String(buffer, 0, len);
				
				if (iaa.equals("1")) {
					
					System.out.println("1--");
					Data = iaa;
					System.out.println(Data);
					client.sendData(Data);
				}
			}
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
}
