This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.
Messages - gudenau
1
« on: November 30, 2014, 05:05:40 pm »
I would like one of these! How much would it cost?
2
« on: October 09, 2013, 07:52:00 pm »
I do think I need struct in there. I do think it can find it just fine as it does not like me making a new struct of the same name.
EDIT: Ok, it looks like removing struct worked... That is needed sometimes, newish to c, but not programming. Thanks for the help.
3
« on: October 09, 2013, 07:19:46 pm »
When I copy the struct from the includes it says that it is already defined. I hope I get better at this soon.
handler.c:
#include <os.h> #include <usbdi.h> #include <usb.h> #include <nspireio2.h> #include "main.h"
int *controllerCount = 0;
static int match(device_t self) { struct usb_attach_arg *uaa = device_get_ivars(self); if (!uaa->iface){ return UMATCH_NONE; } usb_interface_descriptor_t *id = usbd_get_interface_descriptor(uaa->iface); if (!id){ return UMATCH_NONE; } if (id->bInterfaceClass == UICLASS_VENDOR && id->bInterfaceSubClass == UISUBCLASS_XBOX360_CONTROLLER && id->bInterfaceProtocol == UIPROTO_XBOX360_GAMEPAD){ return UMATCH_IFACECLASS; }else{ return UMATCH_NONE; } }
struct softc_360 { // Standered device_t sc_dev; usbd_interface_handle sc_iface; usbd_pipe_handle sc_intrpipe; int sc_ep_addr; struct s_usb_pipe_buf sc_ibuf; int sc_isize; int sc_enabled; // Device specific int16_t buttons; signed char lTrigger; signed char rTrigger; int16_t leftX; int16_t leftY; int16_t rightX; int16_t rightY; };
struct report_360 { char unused[2]; int16_t buttons; signed char lTrigger; signed char rTrigger; int16_t leftX; int16_t leftY; int16_t rightX; int16_t rightY; char unused2[6]; };
static void intr_360(usbd_xfer_handle __attribute__((unused)) xfer, usbd_private_handle addr, usbd_status status){ struct softc_360 *sc = addr; struct report_360 *ibuf = (struct report_360 *)sc->sc_ibuf.buf; if(status != USBD_NORMAL_COMPLETION){ return; } sc->buttons = ibuf->buttons; sc->lTrigger = ibuf->lTrigger; sc->rTrigger = ibuf->rTrigger; sc->leftX = ibuf->leftX; sc->leftY = ibuf->leftY; sc->rightX = ibuf->rightX; sc->rightY = ibuf->rightY; }
static int attach(device_t self){ struct softc_360 *sc = device_get_softc(self); struct usb_attach_arg *uaa = device_get_ivars(self); usbd_status err; if(sc == NULL){ return ENXIO; } sc->sc_iface = uaa->iface; sc->sc_dev = self; usb_endpoint_descriptor_t *ed = usbd_interface2endpoint_descriptor(sc->sc_iface, 0); sc->sc_ep_addr = ed->bEndpointAddress; sc->sc_isize = sizeof(struct softc_360); usbd_set_protocol(sc->sc_iface, 0); usbd_set_idle(sc->sc_iface, 0, 0); sc->sc_ibuf.dummy1 = 0; sc->sc_ibuf.dummy2 = 0; sc->sc_ibuf.buf = malloc(sc->sc_isize); if(!sc->sc_ibuf.buf){ return ENXIO; } err = usbd_open_pipe_intr(sc->sc_iface, sc->sc_ep_addr, USBD_SHORT_XFER_OK, &sc->sc_intrpipe, sc, &sc->sc_ibuf, sc->sc_isize, intr_360, USBD_DEFAULT_INTERVAL); if(err){ free(sc->sc_ibuf.buf); return ENXIO; } sc->sc_enabled = 1; *controllerCount = 1; struct usb_device_request_t ledReq; return 0; }
static int detach(device_t self){ struct softc_360 *sc = device_get_softc(self); if(sc->sc_enabled){ usbd_abort_pipe(sc->sc_intrpipe); usbd_close_pipe(sc->sc_intrpipe); free(sc->sc_ibuf.buf); sc->sc_enabled = 0; } *controllerCount = 0; return 0; }
static int (*methods[])(device_t) = {match, attach, detach, NULL};
void register360(void){ nl_relocdata((unsigned*)methods, sizeof(methods) / sizeof(methods[0]) - 1); usb_register_driver(2, methods, "c360", 0, sizeof(struct softc_360)); FILE *file; file = fopen("/documents/ndless/xboxPointer.cfg.tns", "w"); fwrite(controllerCount, 1, sizeof(controllerCount), file); fclose(file); } Build output:
rm -f *.o *.elf *.tns ./*.gdb nspire-gcc -Wall -W -marm -Os -c handler.c handler.c: In function 'attach': handler.c:118:30: error: storage size of 'ledReq' isn't known handler.c:118:30: warning: unused variable 'ledReq' [-Wunused-variable] make: *** [handler.o] Error 1
4
« on: September 28, 2013, 11:16:00 am »
Mailboxes or shared memory would indeed be a good option. I'll try to add these, but as Lionel says this is unfortunately not the priority. gudenau, you should try the "pointer passed through a shared file" solution in the meantime.
Will do! Thanks for the help, and possible feature.
5
« on: September 27, 2013, 03:37:35 pm »
I think passing your sub program a pointer is the best solution (it's actually the proper way to do it).
Well, the resident application will not be launching the other application, otherwise I would just pass it, to bag I am not just making an operating system for this, would be so much better as it always runs no mater what is the same instance. How should I contact him/her for this?
Just write him a PM.
I will try that. If there are shared memory facilities in Nucleus, Ndless could expose them (once they are found); otherwise, libndls would indeed be the place to implement them.
With the impending release of the next OS version, which will certainly be even closed-minded than 3.2.4, maybe it won't be done before arbitrary code execution, and the subsequent time-consuming and boring work of finding functions again in the new OS version.
I am hoping that this will be a small thing to add.
6
« on: September 27, 2013, 12:28:31 pm »
How should I contact him/her for this?
7
« on: September 26, 2013, 08:01:41 pm »
I did consider that, but I was hoping ndless would have a function for that. Sigh.
8
« on: September 26, 2013, 07:33:45 pm »
That is way to slow, as they can change many times a second, and I do not want to kill the flash.
9
« on: September 26, 2013, 07:05:50 pm »
So, I have two programs, one that needs to be resident and is very small. The other is going to be larger and will unload when not needed. So, how could I access variables from the resident program from the normal one? Unfortunately I can not do this differently.
10
« on: September 20, 2013, 08:52:26 pm »
It had been a while. I am trying to get a good thing going for serial.
Edit: Forgot nl_set_resident();
11
« on: September 19, 2013, 01:56:04 pm »
Crashes with and without hidn by the way.
12
« on: September 18, 2013, 02:11:29 pm »
Let me check, forgot about that!
Edit: Yep, still crashes. :-/
13
« on: September 16, 2013, 08:16:02 pm »
Edit{ Forgot nl_set_resident(); }
So, I am trying to get a hang of the drivers, so I am making a simple one. When I plug the 360 controller in, it crashes my calculator, I thick it is in attach, don't know for sure.
main.c:
#include <os.h> #include <usbdi.h> #include <usb.h> #include <nspireio2.h>
int main(void) { assert_ndless_rev(750); register360(); nl_no_scr_redraw(); nio_grid_puts(0, 0, 12, 1, "360 drivers installed!", is_cx ? NIO_COLOR_BLACK : NIO_COLOR_WHITE, is_cx ? NIO_COLOR_WHITE : NIO_COLOR_BLACK); return 0; }
main.h
#include <os.h> #include <nspireio2.h>
/* handler.c */ void register360(void); handler.c
#include <os.h> #include <usbdi.h> #include <usb.h> #include <nspireio2.h> #include "main.h"
static int match(device_t self) { struct usb_attach_arg *uaa = device_get_ivars(self); if (!uaa->iface){ return UMATCH_NONE; } usb_interface_descriptor_t *id = usbd_get_interface_descriptor(uaa->iface); if (!id){ return UMATCH_NONE; } if (id->bInterfaceClass == UICLASS_VENDOR && id->bInterfaceSubClass == UISUBCLASS_XBOX360_CONTROLLER && id->bInterfaceProtocol == UIPROTO_XBOX360_GAMEPAD){ return UMATCH_IFACECLASS; }else{ return UMATCH_NONE; } }
struct softc_360 { // Standered device_t sc_dev; usbd_interface_handle sc_iface; usbd_pipe_handle sc_intrpipe; int sc_ep_addr; struct s_usb_pipe_buf sc_ibuf; int sc_isize; int sc_enabled; // Device specific int16_t buttons; signed char lTrigger; signed char rTrigger; int16_t leftX; int16_t leftY; int16_t rightX; int16_t rightY; };
struct report_360 { char unused[2]; int16_t buttons; signed char lTrigger; signed char rTrigger; int16_t leftX; int16_t leftY; int16_t rightX; int16_t rightY; char unused2[6]; };
static void intr_360(usbd_xfer_handle __attribute__((unused)) xfer, usbd_private_handle addr, usbd_status status){ struct softc_360 *sc = addr; struct report_360 *ibuf = (struct report_360 *)sc->sc_ibuf.buf; if(status != USBD_NORMAL_COMPLETION){ return; } sc->buttons = ibuf->buttons; sc->lTrigger = ibuf->lTrigger; sc->rTrigger = ibuf->rTrigger; sc->leftX = ibuf->leftX; sc->leftY = ibuf->leftY; sc->rightX = ibuf->rightX; sc->rightY = ibuf->rightY; }
static int attach(device_t self){ struct softc_360 *sc = device_get_softc(self); struct usb_attach_arg *uaa = device_get_ivars(self); usbd_status err; if(sc == NULL){ return ENXIO; } sc->sc_iface = uaa->iface; sc->sc_dev = self; usb_endpoint_descriptor_t *ed = usbd_interface2endpoint_descriptor(sc->sc_iface, 0); sc->sc_ep_addr = ed->bEndpointAddress; sc->sc_isize = sizeof(struct softc_360); usbd_set_protocol(sc->sc_iface, 0); usbd_set_idle(sc->sc_iface, 0, 0); sc->sc_ibuf.dummy1 = 0; sc->sc_ibuf.dummy2 = 0; sc->sc_ibuf.buf = malloc(sc->sc_isize); if(!sc->sc_ibuf.buf){ return ENXIO; } err = usbd_open_pipe_intr(sc->sc_iface, sc->sc_ep_addr, USBD_SHORT_XFER_OK, &sc->sc_intrpipe, sc, &sc->sc_ibuf, sc->sc_isize, intr_360, USBD_DEFAULT_INTERVAL); if(err){ free(sc->sc_ibuf.buf); return ENXIO; } sc->sc_enabled = 1; return 0; }
static int detach(device_t self){ struct softc_360 *sc = device_get_softc(self); if(sc->sc_enabled){ usbd_abort_pipe(sc->sc_intrpipe); usbd_close_pipe(sc->sc_intrpipe); free(sc->sc_ibuf.buf); sc->sc_enabled = 0; } return 0; }
static int (*methods[])(device_t) = {match, attach, detach, NULL};
void register360(void){ nl_relocdata((unsigned*)methods, sizeof(methods) / sizeof(methods[0]) - 1); usb_register_driver(2, methods, "c360", 0, sizeof(struct softc_360)); } Any help?
14
« on: September 11, 2013, 07:07:11 pm »
Well, maybe if I get this going I should get it into ndless itself.
15
« on: September 11, 2013, 03:47:23 pm »
Yah, basically mount points. Thanks for reminding me of the term.
|