Skip to content

Instantly share code, notes, and snippets.

@chrishuan9
Last active August 29, 2015 14:01
Show Gist options
  • Save chrishuan9/790b3563ae5d84459dba to your computer and use it in GitHub Desktop.
Save chrishuan9/790b3563ae5d84459dba to your computer and use it in GitHub Desktop.
Arduino Serial Port in use on MacOSX Fix
--- Fix the Arduino Serial Port in use Issue on OSX Mavericks (10.9) / tested on 10.9.3
--- based on information from: https://github.com/jantje/arduino-eclipse-plugin/issues/129
(* 5.9 /var/lock : Lock files
5.9.1 Purpose
Lock files should be stored within the /var/lock directory structure.
Lock files for devices and other resources shared by multiple applications, such as the serial device lock files that were originally found in either /usr/spool/locks or /usr/spool/uucp, must now be stored in /var/lock. The naming convention which must be used is "LCK.." followed by the base name of the device. For example, to lock /dev/ttyS0 the file "LCK..ttyS0" would be created.
[footnote 35]
The format used for the contents of such lock files must be the HDB UUCP lock file format. The HDB format is to store the process identifier (PID) as a ten byte ASCII decimal number, with a trailing newline. For example, if process 1230 holds a lock file, it would contain the eleven characters: space, space, space, space, space, space, one, two, three, zero, and newline.
[35] Then, anything wishing to use /dev/ttyS0 can read the lock file and act accordingly (all locks in /var/lock should be world-readable). *)
try
display dialog "Fix Arduino's Serial Port is busy issue (Admin privileges needed!)?" buttons ¬
{"Yes, please!", "No, i'm fine."} with icon stop default button 1 giving up after 30
set DlogResult to result
if button returned of result = "Yes, please!" then
do shell script "sudo mkdir -p /var/lock && sudo chmod 0777 /var/lock" with administrator privileges
display dialog "Fix successfully applied." buttons {"Thanks"} with icon note
else
display dialog "Fix was not applied. Try again, if you need to." buttons {"OK"} with icon caution
end if
on error errorMsg number errorNum
display alert "Could not fix it!" message "Try: sudo \"mkdir /var/lock && sudo chomd 0777 /var/lock\" in the Terminal. " & errorMsg buttons "Cancel" default button 1
end try
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment