Here is my code to test push data to port protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.list_device); final int fd1 = HardwareControler.openSerialPort("/dev/s3c2410_serial3", 9600, 8, 1); byte[] frmtest = new byte [2]; frmtest[0] = 1; frmtest[1] = 2; int i = 0, n= 100; for(i=0; i<n; i++) { HardwareControler.write(fd1, frmtest); System.out.println("SEND DATA PORT UART: "+fd1); } } when the program first runs, it does not send anything to the port, then I kill the program using ES Task Manager and run the program again, now the data is sent to the port. i use terminal 1.9v on computer to receive data from tiny210. Why when the program first runs, it does not send anything to the port ?
i can't send data to port board tiny210 OS android
please follow the sequence public int Init_serial() { fd = HardwareControler.openSerialPort("/dev/s3c2410_serial1",115200,8,1); return fd; } public int select() { temp = HardwareControler.select(fd,0,53); return temp; } while (1) { byte data[]={(byte) s.rx[c]}; s.write = s.Send_char(data); } HERE IT IS SENDING CONTINUOUS DATA ON TERMINAL. if u send the no of data then arrange the ARRAY WITH FOR LOOP.
AND THE ADD THE FUNCTION LIKE THIS public int Send_char(byte value[]) { write = HardwareControler.write(fd,value); return write; }
@Kaushal patel when I run the program the first time, I see no data pushed out the com port, then I kill the application and run again, now the data sent to the normal com port. I do not understand why there are cases. my code: xml file: activity_main.xml <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" > <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:padding="@dimen/padding_medium" android:text="@string/hello_world" tools:context=".MainActivity" /> <EditText android:id="@+id/edit_message" android:layout_width="300dp" android:layout_height="50dp" android:hint="@string/edit_message" /> <Button android:id="@+id/button_connect" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/button_connect" android:onClick="connectPort" /> <Button android:id="@+id/button_send" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/button_send" android:onClick="sendMessage" /> </LinearLayout > file java: package com.example.test.serial.port; import android.os.Bundle; import android.app.Activity; import android.content.Intent; import android.view.Menu; import android.view.View; import android.widget.EditText; import android.widget.Toast; import com.friendlyarm.AndroidSDK.HardwareControler; public class MainActivity extends Activity { EditText message; int temp = 0; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); } public void connectPort(View view) { // connect to com port //System.loadLibrary("friendlyarm-hardware"); if(MyApp.fd!=-1) HardwareControler.close(MyApp.fd); else { MyApp.fd = HardwareControler.openSerialPort("/dev/s3c2410_serial3", 9600, 8, 1); if(MyApp.fd!=-1) { Toast.makeText(getApplicationContext(), "Successfull connected to "+MyApp.fd, Toast.LENGTH_SHORT).show(); } } } public void sendMessage(View view) { // send data to com port if(MyApp.fd==-1) Toast.makeText(getApplicationContext(), "not connected to com port", Toast.LENGTH_SHORT).show(); else { message = (EditText)findViewById(R.id.edit_message); MyApp.msg = message.getText().toString(); if(MyApp.msg.equals("")) { Toast.makeText(getApplicationContext(), "It's not text to send", Toast.LENGTH_SHORT).show(); } else { HardwareControler.write(MyApp.fd, MyApp.msg.getBytes()); MyApp.msg = ""; Toast.makeText(getApplicationContext(), "Sent successfull to "+MyApp.fd, Toast.LENGTH_SHORT).show(); } } } static { System.loadLibrary("friendlyarm-hardware"); } }
Hi Kaushal Kaushal patel. I sent data from mini210s to PC right.But i can not recive enough data Ex PC send "hello every body" but Mini210s receive "very body" . [code/] while(true) { err=HardwareControler.select(fd1,0,53); if(err==1){ HardwareControler.read(fd1, Rx_Buffer,255); ReceivedTxt = new String(Rx_Buffer); } public void onClick(View v) { textView1.setText(textView1.getText()+ReceivedTxt); } Can you help me ,please? Thanks. ps: i only use com3 and com2 for RX,Com0 and com 1 are not work.
if i send less than 5 char, 210s receive ok. but my project uses uart to recive data continous,I am fraid miss data.How to Itest can recive data with any lengh? can you tell me way to receive data continous or a long string?
i use HardwareControler.read(fd1,buffer,1) anf For() ; I recieved all data.:D can anyone use COM1 and COM 2 what do RTSn and CTSn work for? and where do they conect? Thanks