Main Restorations Software Audio/Jukebox/MP3 Everything Else Buy/Sell/Trade
Project Announcements Monitor/Video GroovyMAME Merit/JVL Touchscreen Meet Up Retail Vendors
Driving & Racing Woodworking Software Support Forums Consoles Project Arcade Reviews
Automated Projects Artwork Frontend Support Forums Pinball Forum Discussion Old Boards
Raspberry Pi & Dev Board controls.dat Linux Miscellaneous Arcade Wiki Discussion Old Archives
Lightguns Arcade1Up --- Bug Reports --- Site News

Unread posts | New Replies | Recent posts | Rules | Chatroom | Wiki | File Repository | RSS | Submit news

  

Author Topic: Ultrastik 360 + Linux + ultrastikcmd = segmentation fault  (Read 2478 times)

0 Members and 1 Guest are viewing this topic.

BlackGreen

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 15
  • Last login:June 16, 2015, 08:01:26 pm
Ultrastik 360 + Linux + ultrastikcmd = segmentation fault
« on: April 16, 2013, 02:44:33 pm »
Hi:

I've got my linux box up and running with the Ultrastik 360 and SDLmame and things are going great.  As of right now I only have one dilemma.

I've spent most of today trying to get "ultrastikcmd" command to work without creating a segmentation fault.  I have the program built but whenever the call is made to send map data to the 360, a segmentation fault occurs.

I'm running VectorLinux Light 7 with is a flavor of Slackware.  Compilation of ultrastikcmd had no major issues.  I've been using Ultramap in the mean time (separate windows box) to set my maps but in the future this box will be a standalone, so it needs to be able to set joystick maps.

I tried running UltraMap under wine but because UltraMap is looking for the joystick name in a particular manner, wine will never work since Linux never reports the joystick to UltraMap correct.  I don't think this method will ever work.  Maybe "udev" can change the way linux reports the device name?

In regards to the segmentation fault, please see the following lines of code in "ultrastikcmd.cpp":
Code: [Select]
usbret = usb_control_msg(hid->dev_handle,0x43,0xEB,0x0000, 0 , data+(32*i), sizeof(data)/3,1000);
usbret = usb_control_msg(hid->dev_handle,0xC3,0xEA,0x0000, 0 , NULL, 1 ,1000);

The first line above sends the data to the joystick and returns the number of bytes sent, which seems to be ok (32).  The second line is where the actual segment fault is happening (not completely sure on what the command is intended to do).  If I comment out the 2nd line, the program doesn't fault and finishes running, but the joystick is not programmed.

I also noticed that the joystick device node "/dev/input/js0" is gone after making the following call (earlier in the file):
Code: [Select]
ret = hid_force_open(hid, 0, &matcher, 3);
This is my first dive into USB control programming.  Should the "hid_force_open" call be removing the node file?  I tried changing the call to "hid_open" but the call is unable to claim the joystick device.  The "hid_force_open" returns success so I'm assuming it's working.

I was also thinking that maybe the 2nd "usb_control_msg" call is trying to recreate the node file and is unable to due to permissions.  I have to look into udev more and do some testing.

I have run "ultrastikcmd" many times as root with different situations and it has always still faulted.

I haven't been able to get any debug info on where the segment fault is happening, other than manually breaking inside the program at certain spots.

Any help is appreciated.  Other than working with udev, I'm running out of ideas.

BlackGreen

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 15
  • Last login:June 16, 2015, 08:01:26 pm
Re: Ultrastik 360 + Linux + ultrastikcmd = segmentation fault
« Reply #1 on: April 17, 2013, 12:28:58 pm »
Good news - with the help of Aleph (original coder of ultrastikcmd), I was able to get the segmentation fault fixed.

I was also able to fix the problem of the joystick usb connection not rebinding after mapping the Ultrastik.  Previously you would have to do a flash of the map and un/replug the joystick.  The program seems to be working 100% now.

I'll see how Aleph wants to handle the changes and update this thread with more info when I have it.

To fix the segmentation fault, simply change this line of code:
Code: [Select]
usbret = usb_control_msg(hid->dev_handle,0xC3,0xEA,0x0000, 0 , NULL, 1 ,1000);
To:
Code: [Select]
usbret = usb_control_msg(hid->dev_handle,0xC3,0xEA,0x0000, 0 , NULL, 0 ,1000);
« Last Edit: April 17, 2013, 12:31:26 pm by rytz »

BlackGreen

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 15
  • Last login:June 16, 2015, 08:01:26 pm
Re: Ultrastik 360 + Linux + ultrastikcmd = segmentation fault
« Reply #2 on: April 19, 2013, 11:35:40 am »
New version of ultrastikcmd has the fixes:
http://forum.arcadecontrols.com/index.php/topic,91679.0.html

I'll post a small "how to build" guide soon.
« Last Edit: April 19, 2013, 11:37:23 am by rytz »