CRIOMAIN.CPP: translate Korean comments to English, clean UTF-8
Translated all EUC-KR/CP949 Korean developer comments (~35 lines) to English. File re-saved as UTF-8 (was CP949/EUC-KR on disk). Also included: g_dwRIOPollTimeout formula that scales WaitForMultipleObjects timeout by baud rate: clamp(ceil(480000/baud), 5, 50) ms. Key translations: - Developer markers (sanghoon/hyun) - Packet receive loop comments - ACK/NAK handling comments - Thread/COM init comments - Button table comments - Joystick pedal/throttle diagram comments Decorative diamond markers (◆) stripped from case labels and section dividers. Unicode arrows (← →) in diagram comments replaced with ASCII.
This commit is contained in:
@@ -43,7 +43,7 @@ LONG g_LeftPedalLast = 0;
|
||||
LONG g_RightPedalLast = 0;
|
||||
BOOL g_StartGame = FALSE;
|
||||
|
||||
static int g_nOpenComState = 0; // 鉉
|
||||
static int g_nOpenComState = 0; // hyun
|
||||
|
||||
DWORD g_dwLastAnalogUpdate = 0;
|
||||
|
||||
@@ -54,7 +54,7 @@ DWORD g_dwLastAnalogUpdate = 0;
|
||||
#define RESTART_CHAR 0xFE
|
||||
#define IDLE_CHAR 0xFF
|
||||
|
||||
//member 변수처럼 활용할것.
|
||||
//Use it like a member variable.
|
||||
static HANDLE g_hCom = INVALID_HANDLE_VALUE;
|
||||
static OVERLAPPED wos;
|
||||
static OVERLAPPED ros;
|
||||
@@ -108,6 +108,7 @@ int g_nRIOPacketCountB = (sizeof(g_baRIOLengthsB) / sizeof(g_baRIOLengthsB[0]));
|
||||
|
||||
int g_nRIOType = 0; // 0: old(original) type, 1: new type
|
||||
DWORD g_dwRIOBaud = 0; // [tbaud] 0: default by RIO type; else COM1 baud forced by -tbaud (high-speed replica of the original RIO board, protocol unchanged)
|
||||
DWORD g_dwRIOPollTimeout = 50; // [tbaud] WaitForMultipleObjects timeout (ms); computed from baud rate before the receive loop starts
|
||||
int g_nEjectButton = 61; // 61: original, 31: new type
|
||||
BYTE* g_pbRIOLengths = NULL;
|
||||
int g_nRIOPacketCount = 0;
|
||||
@@ -318,7 +319,7 @@ void RequestVersion();
|
||||
void RequestAnalogUpdate(BYTE bFreq = 3);
|
||||
|
||||
// start - for new RIO Board only...
|
||||
//received packet은 각각 다른 스레드에서 처리하므로.. ciritical section이 필요하다..
|
||||
//Received packets are handled in different threads.. a critical section is needed..
|
||||
BYTE received_buffer[128][16];
|
||||
int received_packet=0;//packets count in the received_buffer.
|
||||
DWORD received_serial=0;
|
||||
@@ -569,7 +570,7 @@ BOOL SetupConnection(HANDLE hCom)
|
||||
return TRUE;
|
||||
|
||||
/*
|
||||
원래 처리 루틴..
|
||||
Original processing routine..
|
||||
NPTTYINFO npTTYInfo=0 ;
|
||||
BYTE bset1 = (BYTE) ((FLOWCTRL( npTTYInfo ) & FC_DTRDSR) != 0) ;
|
||||
BYTE bset2 = (BYTE) ((FLOWCTRL( npTTYInfo ) & FC_RTSCTS) != 0) ;
|
||||
@@ -603,7 +604,7 @@ BOOL SetupConnection(HANDLE hCom)
|
||||
|
||||
|
||||
|
||||
//처리되지 않는 항목들.. GetCommState의 기본값으로 처리한다.
|
||||
//Unhandled items.. handled using GetCommState default values.
|
||||
DWORD fDsrSensitivity:1; // DSR sensitivity
|
||||
DWORD fTXContinueOnXoff:1; // XOFF continues Tx
|
||||
DWORD fErrorChar: 1; // enable error replacement
|
||||
@@ -647,7 +648,7 @@ HANDLE OpenConnection(int port)
|
||||
g_hLampEvent = CreateEvent(0,FALSE,0,0);
|
||||
g_hCommWatchThread = CreateThread((LPSECURITY_ATTRIBUTES)NULL, 0, (LPTHREAD_START_ROUTINE)CommWatchProc, NULL, CREATE_SUSPENDED, &g_dwThreadID);
|
||||
if (g_hCommWatchThread) {
|
||||
//Thread까지 정상적으로 생성되었다.
|
||||
//Thread was created successfully.
|
||||
//////////////////////////////////////////////
|
||||
//All OK
|
||||
//Exit Point <======
|
||||
@@ -744,11 +745,11 @@ retry:
|
||||
for(int i=0;i<(int)dwLength;i++){
|
||||
int ch=(BYTE)lpszBlock[i];
|
||||
|
||||
//받은 문자만큼 루프를 돈다.
|
||||
//현재.. 받고 있는 packet이 없고.. 어떤 control문자라도 올 수 있는 상태이다.
|
||||
//Loop for the number of received characters.
|
||||
//Currently.. no packet is being received.. can receive any control character.
|
||||
|
||||
if(packetbyteremain!=0){
|
||||
//패킷에 해당하는 문자가 도착했다.. 나머지 문자들을 받는다.
|
||||
//Character corresponding to a packet has arrived.. receive the remaining characters.
|
||||
if (ch & 0x80) {
|
||||
packetbyteremain=0;
|
||||
chinpacket=0;
|
||||
@@ -758,7 +759,7 @@ retry:
|
||||
packetbytes[chinpacket] = ch;
|
||||
chinpacket++;
|
||||
if (packetbyteremain == 0) {
|
||||
//하나의 패킷이 완성되었다. 도착했다.. 즉시 반응한다.
|
||||
//A packet has been completed and arrived.. respond immediately.
|
||||
chinpacket--; // exclude check byte
|
||||
int packettype=packetbytes[0];
|
||||
BYTE bCheckByte = 0;
|
||||
@@ -837,21 +838,21 @@ retry:
|
||||
packettype++;
|
||||
packettype--;
|
||||
#endif // _DEBUG
|
||||
case rio_Ack2://◆◆◆◆◆◆◆◆◆◆
|
||||
case rio_Ack2:
|
||||
if (g_nRIOType != 0) {
|
||||
BYTE id=packetbytes[1];
|
||||
int popped_index=PopPacket(id);
|
||||
ack_timeout=GetTickCount()+30;
|
||||
if(popped_index==0){
|
||||
//맨처음것... 정상적인 경우이다.
|
||||
//This is the very first one... Normal case.
|
||||
}else if(popped_index>0){
|
||||
//맨처음것이 아닌것.
|
||||
//이전것들이 정상적으로 보내지지 않았으므로 다시 보낸다...
|
||||
ReSendPackets(popped_index);//잘못된 개수 만큼..
|
||||
//Not the very first one.
|
||||
//Previous ones were not sent successfully, resend...
|
||||
ReSendPackets(popped_index);//By the number of incorrect ones..
|
||||
}else{
|
||||
//실패 했다는것은.. 없는 id가 왔다는 것인데..
|
||||
//명백한 에러.. 그러나 특별히 대처할 방법은 없다.
|
||||
//그냥 무시한다.
|
||||
//Failure means an id that does not exist arrived..
|
||||
//An obvious error.. but there is no particular way to handle it.
|
||||
//Simply ignore it.
|
||||
}
|
||||
}
|
||||
break;
|
||||
@@ -870,9 +871,9 @@ retry:
|
||||
// WriteTTYBlock(hWnd,"|",1);
|
||||
chinpacket=0;
|
||||
|
||||
//packetbytes버퍼를 지운다.
|
||||
//Clear the packetbytes buffer.
|
||||
} else {
|
||||
//아직 패킷 문자들이 다 도착하지 않았다.. 아무것도 하지 않는다.
|
||||
//Packet characters have not all arrived yet.. do nothing.
|
||||
;
|
||||
}
|
||||
}else{
|
||||
@@ -889,7 +890,7 @@ retry:
|
||||
}//for(int i=0;i<(int)dwLength;i++)
|
||||
|
||||
|
||||
//상훈 뒤
|
||||
//sanghoon end
|
||||
if (!fReadStat){
|
||||
if (GetLastError() == ERROR_IO_PENDING){
|
||||
while(!GetOverlappedResult( g_hCom,&ros, &dwLength, TRUE )){
|
||||
@@ -1000,12 +1001,22 @@ DWORD FAR PASCAL CommWatchProc( LPSTR lpData )
|
||||
}
|
||||
|
||||
g_dwLastAnalogUpdate = GetTickCount() + 2800;
|
||||
// [tbaud] Scale the poll timeout proportionally to baud rate so faster links
|
||||
// poll more frequently. Formula: clamp(ceil(480000/baud), 5, 50)
|
||||
// preserves the existing 50ms at 9600 baud, floors at 5ms for high speeds.
|
||||
// effectiveBaud: use -tbaud override if set, else the RIO type's default.
|
||||
{
|
||||
DWORD effectiveBaud = (g_dwRIOBaud != 0) ? g_dwRIOBaud
|
||||
: ((g_nRIOType == 0) ? 9600UL : 115200UL);
|
||||
g_dwRIOPollTimeout = min(50UL, max(5UL,
|
||||
(480000UL + effectiveBaud - 1) / effectiveBaud));
|
||||
}
|
||||
while(1) {
|
||||
DWORD dwEvtMask = 0;
|
||||
|
||||
WaitCommEvent( g_hCom, &dwEvtMask,&wcos );
|
||||
|
||||
DWORD ret=WaitForMultipleObjects(3,events,FALSE,50/*INFINITE*/);
|
||||
DWORD ret=WaitForMultipleObjects(3,events,FALSE,g_dwRIOPollTimeout);
|
||||
if(ret==WAIT_OBJECT_0){
|
||||
//An Comm Event has arrived.
|
||||
DWORD bytesread;
|
||||
@@ -1022,10 +1033,10 @@ DWORD FAR PASCAL CommWatchProc( LPSTR lpData )
|
||||
}
|
||||
} else {*/
|
||||
if (g_nRIOType != 0) {
|
||||
///◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆위의 ReadCommBlock에서 ack를 받았을 경우 duetime을 update시킨다.
|
||||
///◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆CheckSentBuffer...
|
||||
///When ack is received from ReadCommBlock above, update duetime.
|
||||
///CheckSentBuffer...
|
||||
if(GetTickCount()>ack_timeout)
|
||||
ReSendPackets(sent_packet);//sent_buffer에 있는 모든것들을 다시 보내본다.
|
||||
ReSendPackets(sent_packet);//Resend everything in sent_buffer.
|
||||
}
|
||||
/*}*/
|
||||
}else if(ret==WAIT_OBJECT_0+1){
|
||||
@@ -1039,9 +1050,9 @@ DWORD FAR PASCAL CommWatchProc( LPSTR lpData )
|
||||
//break;
|
||||
}else if (ret==WAIT_TIMEOUT) {
|
||||
if (g_nRIOType != 0) {
|
||||
///◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆CheckSentBuffer...
|
||||
///CheckSentBuffer...
|
||||
if(GetTickCount()>ack_timeout)
|
||||
ReSendPackets(sent_packet);//sent_buffer에 있는 모든것들을 다시 보내본다.
|
||||
ReSendPackets(sent_packet);//Resend everything in sent_buffer.
|
||||
}
|
||||
if (packetbyteremain == 0) {
|
||||
RequestAnalogUpdate();
|
||||
@@ -1236,8 +1247,8 @@ bool SaveReceivedPacket(const BYTE*ba,int length)
|
||||
|
||||
bool GetSerialFromReceivedBuffer(char * ba)
|
||||
{
|
||||
//ButtonPressed/Released만 저장해 놓는다..
|
||||
//모든 serial packet을 옮긴다.
|
||||
//Store only ButtonPressed/Released..
|
||||
//Transfer all serial packets.
|
||||
if(received_packet>0){
|
||||
if(received_buffer[0][2]==received_serial){
|
||||
CopyMemory(ba,received_buffer[0],16);
|
||||
@@ -1264,7 +1275,7 @@ bool QueuePacket(const BYTE *ba,int length)
|
||||
|
||||
int PopPacket(BYTE id)
|
||||
{
|
||||
//lamp는.. id가..
|
||||
//lamp.. check by id..
|
||||
//search the packet..
|
||||
for(int i=0;i<sent_packet;i++){
|
||||
if(sent_buffer[i][3]==id){
|
||||
@@ -1427,7 +1438,7 @@ void CBUTTON_GROUP::SetTable(BOOL bFlag/* = true*/)
|
||||
|
||||
for (int b = 0; b < MAXBUTTON_TABLE; b++) {
|
||||
s_aCtrlLamp[b] = s_aSaveLamp[b];// = s_aButtonTable[b].lamp;
|
||||
// s_aButtonTable는 Old값이므로 초기치는 Off
|
||||
// s_aButtonTable is the old value, so the initial value is Off
|
||||
s_aButtonTable[b].lamp = LAMP_OFF;
|
||||
}
|
||||
|
||||
@@ -1439,7 +1450,7 @@ void CBUTTON_GROUP::SetTable(BOOL bFlag/* = true*/)
|
||||
}
|
||||
else
|
||||
{
|
||||
// 모든 테이블을 원래 상태로
|
||||
// Restore all tables to original state
|
||||
for (int b = 0; b < MAXBUTTON_TABLE; b++) {
|
||||
s_aCtrlLamp[b] = s_aSaveLamp[b];
|
||||
}
|
||||
@@ -1534,7 +1545,7 @@ void CBUTTON_GROUP::ResetTable(BOOL bFlag/* = true*/)
|
||||
}
|
||||
else
|
||||
{
|
||||
// 모든 테이블을 Off
|
||||
// Turn off all tables
|
||||
for (int b = 0; b < MAXBUTTON_TABLE; b++) {
|
||||
switch(b)
|
||||
{
|
||||
@@ -2212,13 +2223,13 @@ void CRIOMAIN::UpdatePadal (DIJOYSTATE &js)
|
||||
|
||||
Down Up
|
||||
======================
|
||||
← (+) (-) →
|
||||
<-- (+) (-) -->
|
||||
======================
|
||||
↗
|
||||
/^
|
||||
g_LeftPedalStart: INT_MAX (+)
|
||||
|
||||
lP = (LONG)g_LeftPedalStart - g_LeftPedal;
|
||||
lP 결과값은 무조건 음수
|
||||
lP result value is always negative
|
||||
*/
|
||||
|
||||
LONG lP = 0;
|
||||
@@ -2362,9 +2373,9 @@ void CRIOMAIN::UpdateThrottle (DIJOYSTATE &js)
|
||||
|
||||
Up Down
|
||||
======================
|
||||
← (-) (+) →
|
||||
<-- (-) (+) -->
|
||||
======================
|
||||
↗
|
||||
/^
|
||||
g_ThrottleStart: INT_MIN (-)
|
||||
*/
|
||||
|
||||
@@ -2447,11 +2458,11 @@ void CRIOMAIN::UpdateJoystick (DIJOYSTATE &js)
|
||||
*/
|
||||
//////////////////////////////////////////////////////////////////////////////////
|
||||
/*
|
||||
80 의 의미
|
||||
Meaning of 80
|
||||
|
||||
RIO (LEFT :120 ~ RIGHT :-80) 까지의 수를 돌려준다고 가정하고
|
||||
(LEFT의경우) RIGHT 의 최대값 80 이상인 값을 잘라버리고 나머지는
|
||||
버릴경우 LEFT 와 RIGHT가 동일한 속도로 움직일수 있다
|
||||
Assuming RIO returns values in range (LEFT:120 ~ RIGHT:-80)
|
||||
(In the LEFT case) clip values above the RIGHT maximum of 80, and the rest
|
||||
if discarded, LEFT and RIGHT can move at the same speed
|
||||
*/
|
||||
//////////////////////////////////////////////////////////////////////////////////
|
||||
LONG lJ;
|
||||
|
||||
Reference in New Issue
Block a user