Simple single-color 8x8x8 LED Cube with AVRs
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

serialHelper.c 1.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. /*
  2. * unixHelper.c
  3. *
  4. * Copyright 2011 Thomas Buck <xythobuz@me.com>
  5. * Copyright 2011 Max Nuding <max.nuding@gmail.com>
  6. * Copyright 2011 Felix Bäder <baeder.felix@gmail.com>
  7. *
  8. * This file is part of LED-Cube.
  9. *
  10. * LED-Cube is free software: you can redistribute it and/or modify
  11. * it under the terms of the GNU General Public License as published by
  12. * the Free Software Foundation, either version 3 of the License, or
  13. * (at your option) any later version.
  14. *
  15. * LED-Cube is distributed in the hope that it will be useful,
  16. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  18. * GNU General Public License for more details.
  19. *
  20. * You should have received a copy of the GNU General Public License
  21. * along with LED-Cube. If not, see <http://www.gnu.org/licenses/>.
  22. */
  23. #include <stdlib.h>
  24. #include <stdio.h>
  25. #include <jni.h>
  26. #include "serialInterface.h"
  27. #ifdef winHelper
  28. #include "helper/winSerial.c"
  29. #else
  30. #include "helper/unixSerial.c"
  31. #endif
  32. JNIEXPORT jstring JNICALL Java_HelperUtility_getPorts(JNIEnv *env, jclass class) {
  33. char **ports = getSerialPorts();
  34. char *string = NULL;
  35. int length = 0, leng2 = 0, lengthabs = 0;;
  36. while (ports[length] != NULL) {
  37. while (ports[length][leng2] != '\0') {
  38. leng2++;
  39. }
  40. lengthabs += leng2;
  41. leng2 = 0;
  42. length++;
  43. }
  44. length += lengthabs;
  45. string = (char *)malloc((length * sizeof(char)) + 1);
  46. length = 0;
  47. lengthabs = 0;
  48. while (ports[length] != NULL) {
  49. leng2 = 0;
  50. while (ports[length][leng2] != '\0') {
  51. string[lengthabs++] = ports[length][leng2++];
  52. }
  53. string[lengthabs++] = '\n';
  54. length++;
  55. }
  56. string[lengthabs] = '\0';
  57. jstring ret = (*env)->NewStringUTF(env, string);
  58. return ret;
  59. }
  60. JNIEXPORT jshortArray JNICALL Java_HelperUtility_readData(JNIEnv *env, jclass class, jint length) {
  61. return NULL;
  62. }
  63. JNIEXPORT void JNICALL Java_HelperUtility_writeData(JNIEnv *env, jclass class, jshortArray data, jint length) {
  64. return;
  65. }