Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

106 lines
2.2 KiB

  1. #include <string.h>
  2. #include <stdio.h>
  3. #include <stdlib.h>
  4. #include "windows.h"
  5. DWORD SV[][2] = {
  6. -1,-1,
  7. -1,0,
  8. -1,1,
  9. -1,100,
  10. -1,1024,
  11. -1,4096,
  12. -1,10000,
  13. 0,-1,
  14. 0,0,
  15. 0,1,
  16. 0,100,
  17. 0,1024,
  18. 0,4096,
  19. 0,10000,
  20. 1,-1,
  21. 1,0,
  22. 1,1,
  23. 1,100,
  24. 1,1024,
  25. 1,4096,
  26. 1,10000,
  27. 100,0,
  28. 100,1,
  29. 100,100,
  30. 100,1024,
  31. 100,4096,
  32. 100,10000,
  33. 1024,-1,
  34. 1024,0,
  35. 1024,1,
  36. 1024,100,
  37. 1024,1024,
  38. 1024,4096,
  39. 1024,10000,
  40. 4096,-1,
  41. 4096,0,
  42. 4096,1,
  43. 4096,100,
  44. 4096,1024,
  45. 4096,4096,
  46. 4096,10000,
  47. 10000,-1,
  48. 10000,0,
  49. 10000,1,
  50. 10000,100,
  51. 10000,1024,
  52. 10000,4096,
  53. 10000,10000
  54. };
  55. void main(int argc,char *argv[]) {
  56. char *MyPort = "COM1";
  57. HANDLE hFile;
  58. int j;
  59. if (argc > 1) {
  60. MyPort = argv[1];
  61. }
  62. if ((hFile = CreateFile(
  63. MyPort,
  64. GENERIC_READ | GENERIC_WRITE,
  65. 0,
  66. NULL,
  67. CREATE_ALWAYS,
  68. FILE_ATTRIBUTE_NORMAL | FILE_FLAG_OVERLAPPED,
  69. NULL
  70. )) != ((HANDLE)-1)) {
  71. printf("We successfully opened the %s port.\n",MyPort);
  72. for (
  73. j = 0;
  74. j < sizeof(SV)/(sizeof(DWORD)*2);
  75. j++
  76. ) {
  77. printf("SetupComm(hFile,%d,%d)\n",SV[j][1],SV[j][2]);
  78. if (!SetupComm(hFile,SV[j][1],SV[j][2])) {
  79. printf("Couldn't do CommSetup(hFile,%d,%d) %d\n",SV[j][1],SV[j][2],GetLastError());
  80. }
  81. }
  82. } else {
  83. printf("Couldn't open the comm port\n");
  84. }
  85. }