středa 28. března 2012

... dsquery needs to be elevated to query memberOf

Today after an hour of pain I have discovered weird beavior od dsquery command. I was trying to reproduce my yesterday work. Yesterday I queried users based on their membership using following filter in dsquery *.

(&(objectClass=inetOrgPerson)(memberOf=GROUPDN))

Yesterday it worked. Today .. no user is found. After a fair ammount of time I found a solution. Queires containing memberOf as part of the filter need to be executed inisde ELEVATED prompt.

Let me scream again .. UAC on the server is EVIL.

pátek 2. března 2012

Arduino Uno serial communication

Disclaimer: following procedure worked for me. Obviously there is no  guarantee that it will work for you but there is pretty high probability of success. Improper handling can damage or destroy the board but it is unlikely. 

Great little Arduino has one drawback for "production" operation. After (USB)serial port is connected from PC, the unit resets.

The feature is suitable for development - each serial connect enables upload of the code. But it is annoying during production when you may need to connect to your Arduino to collect data. There is a HW solution.

There is a RESET-EN trace on the board (see below - it is located in the green circle marked with RESET-EN label). When the RESET-EN trace is cut (see the red line below - be rough enough when cutting to be sure it is cut) the serial communication initiated resets are disabled. The trace can be soldered again in the future (see Arduino.cc section Automatic (software) reset for reference).



After the RESET-EN trace is cut PC can connect and disconnect the serial and Arduino does not reset. On Linux simple shell scripts can be used to collect the data. Attention - uploading the new code to the Arduino might be a little less comfortable. To upload the new code use the following procedure (i can't find the link of the site where I have discover this procedure):
  1. prepare the sketch in the Arduino IDE
  2. place the mouse pointer at the upload button on the screen
  3. press and hold reset button on the Arduino board 
  4. fix your eyes on RX LED on the Arduino board
  5. click the upload icon in the Arduino IDE
  6. look at the RX LED and after it flashes once release the reset button
  7. look at the Arduino IDE to whether upload was successfull
  8. when the upload fails don't worry and try again with a little different timing of reset button release
  9. it needs little practising but it definitely works for me
  10. ... be patient :-)     
Or you can use alternative approach :
  1. prepare the sketch in the Arduino IDE
  2. place the mouse pointer at the upload button on the screen
  3. look at the status bar of the Arduino IDE
  4. press upload button 
  5. "Compiling sketch ..." will be displayed in the status bar
  6. After several seconds it changes to "Uploading ..."
  7. Press reset on the Arduino board as soon as possible after "Uploading .." comes up
  8. keep practising and you will succsseed

At first the correct serial setup is needed. To setup serial port to be readable using shell utilities use:

stty -F dev/ttyXXX cs8 9600 raw

And then you can use basci text utils to process Arduino output. To read 5 lines from Arduino to a file use:

cat /dev/ttyXXX | head -n 5 > data.txt

And to write command to Arduino just:

echo -n CMD > /dev/ttyXXX

Good luck ...