Skip to content
Browse files

Bugfix Commit

- minor bugfixes because of using macro!
  • Loading branch information...
1 parent 762411e commit 19c2844a7a193e15bbe4acdf67b816f7593b5a7e @azman committed Mar 2, 2012
Showing with 14 additions and 11 deletions.
  1. +7 −7 src/my1comlib.c
  2. +1 −1 src/my1comport.c
  3. +6 −3 src/my1termu.c
View
14 src/my1comlib.c
@@ -69,7 +69,7 @@ int open_serial(ASerialPort_t* aPort)
if(aPort->mHandle==INVALID_HANDLE_VALUE
&&aPort->mPortIndex!=INVALID_PORT_INDEX)
{
- sprintf(cCommPort,"%s%d",aPort->mPortName,aPort->mPortIndex);
+ sprintf(cCommPort,"%s%d",aPort->mPortName,COM_PORT(aPort->mPortIndex));
#ifdef DO_MINGW
aPort->mHandle = CreateFile(cCommPort,GENERIC_READ|GENERIC_WRITE,
0,0x0,OPEN_EXISTING,0,0x0); // NON-OVERLAPPED
@@ -143,10 +143,10 @@ int find_serial(ASerialPort_t* aPort, int *pCount)
int cTest, cCount = 0, cFirst = 0;
if(aPort->mHandle!=INVALID_HANDLE_VALUE)
- return -1; // port opened!
+ return INVALID_PORT_INDEX; // port opened!
for(cTest=1;cTest<=MAX_COM_PORT;cTest++)
{
- if(check_serial(aPort,COM_PORT(cTest)))
+ if(check_serial(aPort,cTest))
{
if(!cFirst) cFirst = cTest;
cCount++;
@@ -166,9 +166,9 @@ int check_serial(ASerialPort_t* aPort, int anIndex)
#else
long cHandle;
#endif
- if(anIndex<COM_PORT(1)||anIndex>COM_PORT(MAX_COM_PORT))
+ if(COM_PORT(anIndex)<COM_PORT(1)||COM_PORT(anIndex)>COM_PORT(MAX_COM_PORT))
return 0;
- sprintf(cCommPort,"%s%d",aPort->mPortName,anIndex);
+ sprintf(cCommPort,"%s%d",aPort->mPortName,COM_PORT(anIndex));
#ifdef DO_MINGW
cHandle = CreateFile(cCommPort,GENERIC_READ | GENERIC_WRITE,
0,NULL,OPEN_EXISTING,0,NULL);
@@ -189,9 +189,9 @@ int check_serial(ASerialPort_t* aPort, int anIndex)
int set_serial(ASerialPort_t* aPort, int anIndex)
{
if(!check_serial(aPort,anIndex))
- return INVALID_PORT_INDEX;
+ return 0;
aPort->mPortIndex = anIndex;
- return aPort->mPortIndex;
+ return anIndex;
}
//------------------------------------------------------------------------------
int get_serial(ASerialPort_t* aPort)
View
2 src/my1comport.c
@@ -14,7 +14,7 @@ void print_portscan(ASerialPort_t* aPort)
printf("--------------------\n");
for(test=1;test<=MAX_COM_PORT;test++)
{
- if(check_serial(aPort,COM_PORT(test)))
+ if(check_serial(aPort,test))
{
printf("%s%d: ",aPort->mPortName,COM_PORT(test));
cCount++;
View
9 src/my1termu.c
@@ -174,7 +174,8 @@ int main(int argc, char* argv[])
{
about();
print_portscan(&cPort);
- printf("\n\nCannot prepare port with name '%s'!\n\n",cPort.mPortName);
+ printf("\n\nCannot prepare port '%s%d'!\n\n",cPort.mPortName,
+ COM_PORT(terminal));
return ERROR_GENERAL;
}
// apply fastport option
@@ -183,7 +184,8 @@ int main(int argc, char* argv[])
// try opening port
if(!open_port(&cPort))
{
- printf("\n\nCannot open port '%s%d'!\n\n",cPort.mPortName,cPort.mPortIndex);
+ printf("\n\nCannot open port '%s%d'!\n\n",cPort.mPortName,
+ COM_PORT(cPort.mPortIndex));
return ERROR_GENERAL;
}
@@ -291,7 +293,8 @@ int main(int argc, char* argv[])
printf("\n\nProgram '%s' - Current Settings:\n",PROGNAME);
if(isopened_port(&cPort))
{
- printf("\nConnected to '%s%d'!",cPort.mPortName,cPort.mPortIndex);
+ printf("\nConnected to '%s%d'!",cPort.mPortName,
+ COM_PORT(cPort.mPortIndex));
}
else printf("\nNOT connected?!");
if(options&OPT_FASTPORT) printf("\nUsing 115200-8N1 Connection.");

0 comments on commit 19c2844

Please sign in to comment.
Something went wrong with that request. Please try again.