kopia lustrzana https://github.com/N0BOY/FT8CN
TrUSDXRig: Initial work for (tr)uSDX's stream over CAT
Remove unused commandpull/67/head
rodzic
824b4bdd00
commit
b905f92cf3
|
@ -50,4 +50,5 @@ FlexRadio 6000 series,00,00,12
|
|||
FX-4CR,00,115200,7
|
||||
Qrp Labs QDX,00,9600,7
|
||||
UA3REO Wolf SDR(DIGU),00,4800,15
|
||||
UA3REO Wolf SDR(USB),00,4800,16
|
||||
UA3REO Wolf SDR(USB),00,4800,16
|
||||
(tr)uSDX,00,115200,17
|
||||
|
|
|
@ -79,6 +79,7 @@ import com.bg7yoz.ft8cn.rigs.Yaesu38Rig;
|
|||
import com.bg7yoz.ft8cn.rigs.Yaesu38_450Rig;
|
||||
import com.bg7yoz.ft8cn.rigs.Yaesu39Rig;
|
||||
import com.bg7yoz.ft8cn.rigs.YaesuDX10Rig;
|
||||
import com.bg7yoz.ft8cn.rigs.TrUSDXRig;
|
||||
import com.bg7yoz.ft8cn.spectrum.SpectrumListener;
|
||||
import com.bg7yoz.ft8cn.timer.OnUtcTimer;
|
||||
import com.bg7yoz.ft8cn.timer.UtcTimer;
|
||||
|
@ -773,6 +774,8 @@ public class MainViewModel extends ViewModel {
|
|||
break;
|
||||
case InstructionSet.WOLF_SDR_USB:
|
||||
baseRig = new Wolf_sdr_450Rig(true);
|
||||
case InstructionSet.TRUSDX:
|
||||
baseRig = new TrUSDXRig();//(tr)uSDX
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -918,4 +921,4 @@ public class MainViewModel extends ViewModel {
|
|||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -61,6 +61,13 @@ public class CableConnector extends BaseRigConnector {
|
|||
cableSerialPort.sendData(command);//以CAT指令发送PTT
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendWaveData(float[] data) {
|
||||
// TODO float to byte
|
||||
// TODO replace `;` to ':'
|
||||
// sendData(wave);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void connect() {
|
||||
super.connect();
|
||||
|
|
|
@ -130,4 +130,8 @@ public abstract class BaseRig {
|
|||
public boolean isPttOn() {
|
||||
return isPttOn;
|
||||
}
|
||||
|
||||
public boolean supportWaveOverCAT() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,5 +18,5 @@ public class InstructionSet {
|
|||
public static final int KENWOOD_TS2000=14;//建武TS2000,发射指令是TX0;
|
||||
public static final int WOLF_SDR_DIGU=15;//UA3REO Wolf SDR,DIG-U模式,兼容YAESU 450D;
|
||||
public static final int WOLF_SDR_USB=16;//UA3REO Wolf SDR,USB模式,兼容YAESU 450D;
|
||||
|
||||
public static final int TRUSDX=17;//(tr)USDX;
|
||||
}
|
||||
|
|
|
@ -37,6 +37,11 @@ public class KenwoodTK90RigConstant {
|
|||
private static final String TS590_READ_FREQ = "FA;";//KENWOOD 读频率
|
||||
private static final String TS590_READ_METERS = "RM;";//KENWOOD 读METER
|
||||
|
||||
// (tr)uSDX extensions
|
||||
private static final String TRUSDX_STREAMING_OFF="UA0;";
|
||||
private static final String TRUSDX_STREAMING_ON_SPEAKER_ON="UA1;";
|
||||
private static final String TRUSDX_STREAMING_ON_SPEAKER_OFF="UA2;";
|
||||
private static final String TRUSDX_STREAMING_AUDIO="US";
|
||||
|
||||
|
||||
|
||||
|
@ -132,4 +137,11 @@ public class KenwoodTK90RigConstant {
|
|||
return TS590_READ_FREQ.getBytes();
|
||||
}
|
||||
|
||||
public static byte[] setTrUSDXStreaming(boolean on) {
|
||||
if (on) {
|
||||
return TRUSDX_STREAMING_ON_SPEAKER_OFF.getBytes();
|
||||
} else {
|
||||
return TRUSDX_STREAMING_OFF.getBytes();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,202 @@
|
|||
package com.bg7yoz.ft8cn.rigs;
|
||||
|
||||
import static com.bg7yoz.ft8cn.GeneralVariables.QUERY_FREQ_TIMEOUT;
|
||||
import static com.bg7yoz.ft8cn.GeneralVariables.START_QUERY_FREQ_DELAY;
|
||||
|
||||
import android.os.Handler;
|
||||
import android.util.Log;
|
||||
|
||||
import com.bg7yoz.ft8cn.GeneralVariables;
|
||||
import com.bg7yoz.ft8cn.R;
|
||||
import com.bg7yoz.ft8cn.database.ControlMode;
|
||||
import com.bg7yoz.ft8cn.ui.ToastMessage;
|
||||
|
||||
import java.util.Timer;
|
||||
import java.util.TimerTask;
|
||||
|
||||
/**
|
||||
* (tr)uSDX, fork from KENWOOD TS590.
|
||||
*/
|
||||
public class TrUSDXRig extends BaseRig {
|
||||
private static final String TAG = "TrUSDXRig";
|
||||
private final StringBuilder buffer = new StringBuilder();
|
||||
|
||||
private Timer readFreqTimer = new Timer();
|
||||
private int swr=0;
|
||||
private int alc=0;
|
||||
private boolean alcMaxAlert = false;
|
||||
private boolean swrAlert = false;
|
||||
|
||||
private TimerTask readTask() {
|
||||
return new TimerTask() {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
if (!isConnected()) {
|
||||
readFreqTimer.cancel();
|
||||
readFreqTimer.purge();
|
||||
readFreqTimer = null;
|
||||
return;
|
||||
}
|
||||
if (isPttOn()){
|
||||
readMeters();//读METER
|
||||
}else {
|
||||
readFreqFromRig();//读频率
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
Log.e(TAG, "readFreq error:" + e.getMessage());
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* 读取Meter RM;
|
||||
*/
|
||||
private void readMeters(){
|
||||
if (getConnector() != null) {
|
||||
clearBufferData();//清空一下缓存
|
||||
getConnector().sendData(KenwoodTK90RigConstant.setRead590Meters());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 清空缓存数据
|
||||
*/
|
||||
private void clearBufferData() {
|
||||
buffer.setLength(0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPTT(boolean on) {
|
||||
super.setPTT(on);
|
||||
if (getConnector() != null) {
|
||||
switch (getControlMode()) {
|
||||
case ControlMode.CAT://以CIV指令
|
||||
getConnector().setPttOn(KenwoodTK90RigConstant.setTS590PTTState(on));
|
||||
break;
|
||||
case ControlMode.RTS:
|
||||
case ControlMode.DTR:
|
||||
getConnector().setPttOn(on);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isConnected() {
|
||||
if (getConnector() == null) {
|
||||
return false;
|
||||
}
|
||||
return getConnector().isConnected();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setUsbModeToRig() {
|
||||
if (getConnector() != null) {
|
||||
getConnector().sendData(KenwoodTK90RigConstant.setTS590OperationUSBMode());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFreqToRig() {
|
||||
if (getConnector() != null) {
|
||||
getConnector().sendData(KenwoodTK90RigConstant.setTS590OperationFreq(getFreq()));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onReceiveData(byte[] data) {
|
||||
String s = new String(data);
|
||||
|
||||
if (!s.contains("\r"))
|
||||
{
|
||||
buffer.append(s);
|
||||
if (buffer.length()>1000) clearBufferData();
|
||||
//return;//说明数据还没接收完。
|
||||
}else {
|
||||
if (s.indexOf("\r")>0){//说明接到结束的数据了,并且不是第一个字符是;
|
||||
buffer.append(s.substring(0,s.indexOf("\r")));
|
||||
}
|
||||
//开始分析数据
|
||||
Yaesu3Command yaesu3Command = Yaesu3Command.getCommand(buffer.toString());
|
||||
clearBufferData();//清一下缓存
|
||||
//要把剩下的数据放到缓存里
|
||||
buffer.append(s.substring(s.indexOf("\r")+1));
|
||||
|
||||
if (yaesu3Command == null) {
|
||||
return;
|
||||
}
|
||||
String cmd=yaesu3Command.getCommandID();
|
||||
if (cmd.equalsIgnoreCase("FA")) {//频率
|
||||
long tempFreq=Yaesu3Command.getFrequency(yaesu3Command);
|
||||
if (tempFreq!=0) {//如果tempFreq==0,说明频率不正常
|
||||
setFreq(Yaesu3Command.getFrequency(yaesu3Command));
|
||||
}
|
||||
}else if (cmd.equalsIgnoreCase("RM")){//meter
|
||||
if (Yaesu3Command.is590MeterSWR(yaesu3Command)) {
|
||||
swr = Yaesu3Command.get590ALCOrSWR(yaesu3Command);
|
||||
}
|
||||
if (Yaesu3Command.is590MeterALC(yaesu3Command)) {
|
||||
alc = Yaesu3Command.get590ALCOrSWR(yaesu3Command);
|
||||
}
|
||||
showAlert();
|
||||
}else if (cmd.equalsIgnoreCase("US")){//wave
|
||||
// TODO
|
||||
byte[] buf = yaesu3Command.getData().getBytes();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
private void showAlert() {
|
||||
if (swr >= KenwoodTK90RigConstant.ts_590_swr_alert_max) {
|
||||
if (!swrAlert) {
|
||||
swrAlert = true;
|
||||
ToastMessage.show(GeneralVariables.getStringFromResource(R.string.swr_high_alert));
|
||||
}
|
||||
} else {
|
||||
swrAlert = false;
|
||||
}
|
||||
if (alc > KenwoodTK90RigConstant.ts_590_alc_alert_max) {//网络模式下不警告ALC
|
||||
if (!alcMaxAlert) {
|
||||
alcMaxAlert = true;
|
||||
ToastMessage.show(GeneralVariables.getStringFromResource(R.string.alc_high_alert));
|
||||
}
|
||||
} else {
|
||||
alcMaxAlert = false;
|
||||
}
|
||||
|
||||
}
|
||||
@Override
|
||||
public void readFreqFromRig() {
|
||||
if (getConnector() != null) {
|
||||
clearBufferData();//清空一下缓存
|
||||
getConnector().sendData(KenwoodTK90RigConstant.setTS590ReadOperationFreq());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "(tr)uSDX";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean supportWaveOverCAT() {
|
||||
return getConnector() != null && getControlMode() == ControlMode.CAT;
|
||||
}
|
||||
|
||||
public TrUSDXRig() {
|
||||
new Handler().postDelayed(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (getConnector()!=null){
|
||||
getConnector().sendData(KenwoodTK90RigConstant.setTS590VFOMode());
|
||||
getConnector().sendData(KenwoodTK90RigConstant.setTrUSDXStreaming(true));
|
||||
}
|
||||
}
|
||||
},START_QUERY_FREQ_DELAY-500);
|
||||
readFreqTimer.schedule(readTask(), START_QUERY_FREQ_DELAY,QUERY_FREQ_TIMEOUT);
|
||||
}
|
||||
}
|
Ładowanie…
Reference in New Issue