/* -*- mode: jde; c-basic-offset: 2; indent-tabs-mode: nil -*- */

package processing.app.debug;

import processing.app.Base;
import processing.app.Preferences;
import processing.app.Serial;
import processing.app.SerialException;

import java.io.*;
import java.util.*;
import java.util.zip.*;
import javax.swing.*;
import gnu.io.*;

public class CC3200Uploader extends Uploader{
	public CC3200Uploader() {
	}
	public boolean uploadUsingPreferences(String buildPath, String className, boolean usingProgrammer)
	throws RunnerException, SerialException {
		this.verbose = verbose;
		Map<String, String> boardPreferences = Base.getBoardPreferences();
		Target target = Base.getTarget();
		Collection params = new ArrayList();

		String uploadPort = Preferences.get("serial.port");

		if (Base.isMacOS() || Base.isLinux()) {
			params.add(uploadPort);
			if ( Base.isLinux()) {
				params.add(buildPath + File.separator + className + ".bin");
			}
			else { 
				params.add(buildPath + File.separator + className + ".bin");
			}
		} else {
			params.add(uploadPort.substring(3));
			params.add(buildPath + File.separator + className + ".bin");
		}
		return serial(params);
	}

	public boolean burnBootloader() throws RunnerException {
		//nothing do do for MSP430
		return false;
	}

	public boolean serial(Collection params) throws RunnerException {
		List commandDownloader = new ArrayList();

		if ( Base.isLinux()) {
			commandDownloader.add(Base.getLM4FBasePath() + "serial");
		} 
		else if (Base.isMacOS()) {
			commandDownloader.add(Base.getLM4FBasePath() + "serial");
		}
		else {
			commandDownloader.add(Base.getLM4FBasePath() + "serial");
		}
		commandDownloader.addAll(params);
		
		return executeUploadCommand(commandDownloader);
	}
}


@@ -1145,22 +1145,26 @@
 %09return 
-serial
+cc3200prog
 (params)
@@ -1292,22 +1292,26 @@
 boolean 
-serial
+cc3200prog
 (Collect
@@ -1464,30 +1464,34 @@
 sePath() + %22
-serial
+cc3200prog
 %22);%0A%09%09%7D %0A%09%09e
@@ -1559,38 +1559,42 @@
 4FBasePath() + %22
-serial
+cc3200prog
 %22);%0A%09%09%7D%0A%09%09else %7B
@@ -1645,22 +1645,26 @@
 th() + %22
-serial
+cc3200prog
 %22);%0A%09%09%7D%0A

Rename serial -> cc3200prog