CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

PK2CMD && CCS && RUBY[off topic]

 
Post new topic   Reply to topic    CCS Forum Index -> Code Library
View previous topic :: View next topic  
Author Message
stinky



Joined: 05 Mar 2012
Posts: 99
Location: Central Illinois

View user's profile Send private message

PK2CMD && CCS && RUBY[off topic]
PostPosted: Mon Feb 09, 2015 5:06 pm     Reply with quote

I'm not sure how many of you here are command line junkies. If you are, I've been using a ruby script that has been most helpful for running the command line version of the PICKit2.

You'll need these:
PK2CMD and more from microchip
Ruby for windows
Rupy for other OSes

-I don't keep more than one .hex in a given directory. If you do, this script will try and load all the .hex files it finds. YMMV.
-You must add pk2cmd.exe to your path.
-You must add ruby to your path, but the installers may do it for you.
-I have it set to release MCLR after programming.
-Copy, paste, and save it as whatever.rb
-Call the script with "ruby whatever.rb" from the directory that has the generated .hex file.
-Hope this helps. I know ruby is outside of this forum's scope. I promise it is easy to pickup though. Lots of good info out there.


Code:
#call script from the same directory
#that the compiled HEX file is in.
Dir.glob("*.hex").each do |f|
   path_to_file = File.path("#{f}").gsub('/', '\\')
   puts "#{f}"

  #ccs hex files have the devie
  #name inside.  This looks for
  #that name.
  query = 'PIC'
  names = File.readlines(path_to_file)
  matches = names.select { |name| name[/#{query}/i] }
  device = matches[0].to_s.sub!(/^;/,'').chomp

  #use the device name and file to
  #create the command passed to the
  #pickit2 programmer-T
  command = "pk2cmd /P#{device} /R /M /F#{path_to_file}"

  #program the device and return
  #the stderr display
  pk2 = (IO.popen "#{command}")
  puts pk2.readlines

  puts
end
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> Code Library All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group