Jump to content

Opening serial connection


Recommended Posts

Guest zero_divide_1
Posted

Okay, I have no idea how to open serial ports and read/write to them, but I guess now is as good of a time as any. I'm trying to write a homescreen plugin that displays the subscriber's phone number(s) underneath the current operator text plugin. I'm trying to open the "RIL1:" port and issue the appropriate AT command, but for some reason when I do a ReadFile it always results in "0" being the number of bytes read. Can somebody let me know what the correct procedure is for reading/writing to this port? Source code (not for the XDA though) would be appreciated too! Thanx!

Guest muff
Posted

isn't there some serial port code in the SDK? seem to remember a project had some in

Guest zero_divide_1
Posted
isn't there some serial port code in the SDK? seem to remember a project had some in

<{POST_SNAPBACK}>

Well, do you know what the code is to open and write to the RIL1: port? It seems WriteFile and ReadFile don't do anything when I open it:

HANDLE hRIL = CreateFile(TEXT("RIL1:"), GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_SYSTEM, NULL);

if(hRIL && hRIL != INVALID_HANDLE_VALUE) {

   DWORD dwBytes = 0;

   if(WriteFile(hRIL, "AT+CNUM\r\n", 9, &dwBytes, NULL) && dwBytes) {

      char buffer[128] = { 0 };

      if(ReadFile(hRIL, buffer, sizeof(buffer), &dwBytes, NULL) && dwBytes) {

         ...

      }

   }

}

CloseHandle(hRIL);

  • 2 months later...
Posted
Well, do you know what the code is to open and write to the RIL1: port? It seems WriteFile and ReadFile don't do anything when I open it:

HANDLE hRIL = CreateFile(TEXT("RIL1:"), GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_SYSTEM, NULL);

if(hRIL && hRIL != INVALID_HANDLE_VALUE) {

   DWORD dwBytes = 0;

   if(WriteFile(hRIL, "AT+CNUM\r\n", 9, &dwBytes, NULL) && dwBytes) {

      char buffer[128] = { 0 };

      if(ReadFile(hRIL, buffer, sizeof(buffer), &dwBytes, NULL) && dwBytes) {

         ...

      }

   }

}

CloseHandle(hRIL);

<{POST_SNAPBACK}>

Just use RIL functions.

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.