Modified ComPrinter version that asks for robot number

Somebody requested a modified version of the ComPrinter program which asks the user to type in the robot ID when it starts up. I’ve created a modifed version that does this, so that you can start the program by double clicking it and then type in the ID of your robot. Here’s the download link:

Highlighted below are the three lines code I added to the program (at line 120):

// Welcome message
if (debug)
	fprintf(stderr, "\nComPrinter.exe - written by Ted Burke\n");
	fprintf(stderr, "\n");
	fprintf(stderr, "This modified version (with robot selection prompt): 29-3-2012\n\n");

// Ask user for robot id number
fprintf(stderr, "Please enter robot ID number: ");
scanf("%d", &id);

// Debug messages
if (debug > 1) fprintf(stderr, "dev_number = %d\n", dev_number);
if (debug > 1) fprintf(stderr, "baudrate = %d\n\n", baudrate);

Here’s what the modified version looks like when you run it:

This entry was posted in Uncategorized and tagged , , . Bookmark the permalink.

4 Responses to Modified ComPrinter version that asks for robot number

  1. paulleamy says:

    Hello Ted,

    Im trying to get my pic to communicate with with my computer using com printer. I have it working with the first version, but when I use the modified version with the ID number I can’t get any communication betwwen the pic and computer.

    Do I need to add the ID number on the pic as well, not entirelt sure how to go about this.


    • batchloaf says:

      Hi Paul. If you’re using the robot ID feature to filter what ComPrinter displays, you need to make sure your PIC code is sending each message in exactly the right format. Firstly, you have to choose a robot ID number. You can pick whatever number you like – I’m going to use the number 7 for this example. Let’s say you want to send the message “Hello world!” from your robot, you need to actually print the following string: “<7@Hello world!>”. The line of C code in your PIC program would be,

          printf("<7@Hello world!>");

      When you run ComPrinter, you specify the ID number of your robot:

          ComPrinter.exe /id 7

      If you’re using the modified version of ComPrinter, it will ask you to type in the ID number of your robot. Either way, when you specify a robot ID number, ComPrinter will only display messages that are in the format described above (“<ID_NUMBER@MESSAGE_TEXT>”) and with the correct ID number.

      The message you print must conform to the above format, but it can contain whatever text you want. For example, let’s say you want to print a sensor reading:

          int sensor_reading;
          sensor_reading = read_analog_channel(0);
          printf("<7@Sensor reading = %d>", sensor_reading);

      Incidentally, the reason I included the robot ID feature in ComPrinter was to allow messages from multiple robots to be selectively filtered into different windows. If you run ComPrinter without specifying a robot ID, it should print all incoming text irrespective of whether it matches the RoboSumo robot format described above. The latest version of ComPrinter can be downloaded from:

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s