Loading ...
Sorry, an error occurred while loading the content.

Re: [kminternals] Trouble running PDDemulate.py on WindowsXP (Brother 930)

Expand Messages
  • Steve Conklin
    I ve never seen this before. The emulator is only reading 861 bytes when it is expecting 1024. Here s what I think is happening, but it s only a guess. I think
    Message 1 of 14 , Apr 16 7:21 PM
    • 0 Attachment
      I've never seen this before. The emulator is only reading 861 bytes when it is expecting 1024.

      Here's what I think is happening, but it's only a guess.

      I think that without using hardware flow control, the emulator is overrunning the serial input buffers on your computer. It could be that the buffer size or input handling is different enough between Linux and Windows that this is a problem that I haven't seen on Linux.

      The serial input is set up in the emulator to time out and return after one second, so if characters are lost it will complete the read after one second but have fewer characters than the knitting machine sent.

      The solution is to use hardware flow control. Make sure that your RS-232 adapter is connected as described in the last table on this page: http://www.antitronics.com/wiki/index.php?title=Electroknit_Serial_Connections

      Also make sure that the pin signals sense is inverted from normal using the FT_PROG utility.

      Now, you need to change the python code in the emulator to open the port with hardware flow control. To do this,
      edit line 287 and change "rtscts=0" to "rtscts=1".

      Let me know if this works. I've started a new version of the emulator which allows using flow control from the command line, but I've been too busy to finish and test it.

      Steve

      On Mon, Apr 16, 2012 at 8:58 PM, bart_930 <bart.acres@...> wrote:
       

      Hi all,
      Have been working on trying to hack my Brother 930 knitting machine. We had a spare old computer sitting around our house, which I reformatted and did a fresh install of XP on it especially (I did this since MProg was Windows only so I thought that was the best option).

      Anyway, I have made it as far as trying to run PDDemulate.py to back up the knitting machine memory. Here is where I'm getting stuck (see image)

      http://i136.photobucket.com/albums/q176/bartacres/brothercommandprompt.jpg

      The connection with the machine is clearly active as the command prompt text progresses when I press buttons on the machine (like 502 or whatever it was)... it creates an img folder in my brother folder, and things show up in there, but no file-01.dat and the other files appear to be blank.

      Any help or suggestions much appreciated!!


    • John R. Hogerhuis
      Hi, Hard time believing that the KM can overrun Windows XP. It should be able to keep up with our old tech, easy peasy. Another possibility is flaky serial
      Message 2 of 14 , Apr 16 7:53 PM
      • 0 Attachment
        Hi,

        Hard time believing that the KM can overrun Windows XP. It should be able to keep up with our old tech, easy peasy.

        Another possibility is flaky serial hardware, cabling or driver (lost interrupts) on the PC side or a environmental dependency in the python serial library. Extend the timeout to something ridiculous, for starters, jiggle the cable and see if the bytes eventually dislodge themselves ;-)   I'm only half kidding... if the cable's flow control is flaky and locking things up, jiggling the cable could allow the bytes to flow. Also the bytes could be stuck in buffers  owned by the serial driver and just waiting could allow background polling to eventually pick them up even if chance to run on interrupt was lost for some reason.

        Do we have a list of USB->Serial adapters and drivers known to work reliably when connected to KH930 on Windows XP? Might be worth putting something together.

        Cheers,

        -- John.

      • bart_930
        Thanks for the reply Steve. I jimmied up my FTDI cable as per the instructions at http://www.ladyada.net/learn/electroknit/ftdicable.html so hopefully they are
        Message 3 of 14 , Apr 16 8:08 PM
        • 0 Attachment
          Thanks for the reply Steve.

          I jimmied up my FTDI cable as per the instructions at http://www.ladyada.net/learn/electroknit/ftdicable.html so hopefully they are accurate. The red cable is split into 2 and inserted into pins 2 and 3.

          I tried the code modification that you suggested above. It definitely changed something. However the problem now is that as soon as I press 552 and hit 'Step', the knitting machine goes blank, seems to basically turn itself off. Here is the resulting output in command prompt:

          http://s136.photobucket.com/albums/q176/bartacres/?action=view¤t=cp1.jpg

          I appreciate your help here Steve, and I know that others have been encountering similar problems, see bottom post here for example http://forums.adafruit.com/viewtopic.php?f=8&p=135370 so it would be awesome to find a solution. I suppose I can always install Ubuntu on my dedicated knitting machine computer if all else fails!
        • bart_930
          Thanks for your reply too John. Update - since I have a computer designated specifically for use with the knitting machine (oh the joys of having room mates
          Message 4 of 14 , Apr 17 8:53 PM
          • 0 Attachment
            Thanks for your reply too John.

            Update - since I have a computer designated specifically for use with the knitting machine (oh the joys of having room mates who like to upgrade their tech often), and I was eager to get my machine up and running, I opted to install Ubuntu as well, its so easy just insert the CD and it creates its own partition, dual boot option etc. Everything is working fine now and I have produced my first knitted panels of custom designs!!

            Thanks guys for being hardcore geeks and getting this info out there.

            My friends here in Dunedin, New Zealand are about to get themselves some crazy ass knitwear!!
          • John R. Hogerhuis
            Indicates to me that it s not a hardware problem so it is either a Python-Windows platform issue or a driver issue. Not a big believer in the flow control
            Message 5 of 14 , Apr 17 9:06 PM
            • 0 Attachment
              Indicates to me that it's not a hardware problem so it is either a
              Python-Windows platform issue or a driver issue.

              Not a big believer in the flow control thing in this case since I
              don't think it's really necessary as request-response is self
              limiting, PC is not going to run out of buffers, and the PC has plenty
              of cycles to spare to handle serial port.

              -- John.
            • jackpups@rocketmail.com
              I am running into the same problem, its only reading 865bytes. But using the FTDI cable with DAK7 and trying to make a backup everything is ok. So i think
              Message 6 of 14 , Apr 23 11:35 AM
              • 0 Attachment
                I am running into the same problem, its only reading 865bytes. But using the FTDI cable with DAK7 and trying to make a backup everything is ok.
                So i think there is something wrong with pddemulate.
              • Steve Conklin
                Are you using hardware flow control, or just using the PDDemulate software as it is? I d really like for someone who is having this problem to try using
                Message 7 of 14 , Apr 23 12:29 PM
                • 0 Attachment
                  Are you using hardware flow control, or just using the PDDemulate software as it is?

                  I'd really like for someone who is having this problem to try using hardware flow control, as described a few emails back in this thread, and see if that solves it.

                  Thanks!

                  Steve

                  On Mon, Apr 23, 2012 at 1:35 PM, jackpups@... <jackpups@...> wrote:
                   

                  I am running into the same problem, its only reading 865bytes. But using the FTDI cable with DAK7 and trying to make a backup everything is ok.
                  So i think there is something wrong with pddemulate.


                • jackpups@rocketmail.com
                  I do use Flow Control, but it doesn t solve the error.
                  Message 8 of 14 , Apr 24 3:37 AM
                  • 0 Attachment
                    I do use Flow Control, but it doesn t solve the error.

                    --- In kminternals@yahoogroups.com, Steve Conklin <steve@...> wrote:
                    >
                    > Are you using hardware flow control, or just using the PDDemulate software
                    > as it is?
                    >
                    > I'd really like for someone who is having this problem to try using
                    > hardware flow control, as described a few emails back in this thread, and
                    > see if that solves it.
                    >
                    > Thanks!
                    >
                    > Steve
                    >
                    > On Mon, Apr 23, 2012 at 1:35 PM, jackpups@... <
                    > jackpups@...> wrote:
                    >
                    > > **
                    > >
                    > >
                    > > I am running into the same problem, its only reading 865bytes. But using
                    > > the FTDI cable with DAK7 and trying to make a backup everything is ok.
                    > > So i think there is something wrong with pddemulate.
                    > >
                    > >
                    > >
                    >
                  • Steve Conklin
                    I don t really have any good ideas about what the problem could be, if it s not a flow control issue. It could possibly be a difference in the way pyserial
                    Message 9 of 14 , Apr 24 8:40 AM
                    • 0 Attachment
                      I don't really have any good ideas about what the problem could be, if it's not a flow control issue.
                      It could possibly be a difference in the way pyserial works under windows.

                      Since bart_930 was able to switch to Linux and have it work, that indicates that the knitting machine is sending the expected amount of data, and the the emulator is expecting the right amount. So the difference has to be something that's affecting the serial data transfer.

                      Sorry, that's all I have to offer at the moment.

                      Steve

                      On Tue, Apr 24, 2012 at 5:37 AM, jackpups@... <jackpups@...> wrote:
                       

                      I do use Flow Control, but it doesn t solve the error.



                      --- In kminternals@yahoogroups.com, Steve Conklin <steve@...> wrote:
                      >
                      > Are you using hardware flow control, or just using the PDDemulate software
                      > as it is?
                      >
                      > I'd really like for someone who is having this problem to try using
                      > hardware flow control, as described a few emails back in this thread, and
                      > see if that solves it.
                      >
                      > Thanks!
                      >
                      > Steve
                      >
                      > On Mon, Apr 23, 2012 at 1:35 PM, jackpups@... <
                      > jackpups@...> wrote:
                      >
                      > > **

                      > >
                      > >
                      > > I am running into the same problem, its only reading 865bytes. But using
                      > > the FTDI cable with DAK7 and trying to make a backup everything is ok.
                      > > So i think there is something wrong with pddemulate.
                      > >
                      > >
                      > >
                      >


                    • John R. Hogerhuis
                      ... I m betting on a problem with pyserial and how it sets up the serial DCB structure or some plain old bug in interaction with the windows api. It sure
                      Message 10 of 14 , Apr 24 9:01 AM
                      • 0 Attachment


                        On Tue, Apr 24, 2012 at 8:40 AM, Steve Conklin <steve@...> wrote:
                         

                        I don't really have any good ideas about what the problem could be, if it's not a flow control issue.
                        It could possibly be a difference in the way pyserial works under windows.


                        I'm betting on a problem with pyserial and how it sets up the serial DCB structure or some plain old bug in interaction with the windows api. It sure smells like a platform dependency to me. Somebody's going to have to get in there with a protocol analyzer though to prove it.

                        There are software-only sniffers like

                        Portmon

                        That MIGHT give some clues.

                        There seem to be a lot of these programs around. Maybe someone can recommend a good Windows one that would be worth looking at.

                        A hardware sniffer or a software "man in the middle" two-serial-port thing is the ultimate tool for this work.

                        -- John.
                      • Steve Conklin
                        For hardware sniffing, this unit works for me: http://www.saleae.com/logic It s 5V only input, but it has protocol analyzers for async serial and a lot of
                        Message 11 of 14 , Apr 24 9:16 AM
                        • 0 Attachment
                          For hardware sniffing, this unit works for me:


                          It's 5V only input, but it has protocol analyzers for async serial and a lot of other protocols.
                          I've been very happy with mine.

                          I don't have ownership or interest in the company that makes these, I just thought I'd mention it, since it's the tool I use.

                          Steve

                          On Tue, Apr 24, 2012 at 11:01 AM, John R. Hogerhuis <jhoger@...> wrote:
                           



                          On Tue, Apr 24, 2012 at 8:40 AM, Steve Conklin <steve@...> wrote:
                           

                          I don't really have any good ideas about what the problem could be, if it's not a flow control issue.
                          It could possibly be a difference in the way pyserial works under windows.


                          I'm betting on a problem with pyserial and how it sets up the serial DCB structure or some plain old bug in interaction with the windows api. It sure smells like a platform dependency to me. Somebody's going to have to get in there with a protocol analyzer though to prove it.

                          There are software-only sniffers like

                          Portmon

                          That MIGHT give some clues.

                          There seem to be a lot of these programs around. Maybe someone can recommend a good Windows one that would be worth looking at.

                          A hardware sniffer or a software "man in the middle" two-serial-port thing is the ultimate tool for this work.

                          -- John.


                        • andy.caslaw
                          Bart and others, I was having the exact same error on XP, Error, write of N bytes when expecting 1024 , with N around 900 from multiple attempts. I found that
                          Message 12 of 14 , May 6, 2012
                          • 0 Attachment
                            Bart and others,

                            I was having the exact same error on XP, "Error, write of N bytes when expecting 1024", with N around 900 from multiple attempts.

                            I found that by changing from timeout=1 second, to timeout=10 seconds ( or timeout=none ) the problem went away.

                            I changed this line in PDDEmulator.py to...

                                        self.ser = serial.Serial(port=cport, baudrate=9600, parity='N', stopbits=1, timeout=10, xonxoff=0, rtscts=0, dsrdtr=0)

                            I'm using the FTDI TTL-232R-5V cable with TXD/RXD/CTS/RTS all inverted and connected with KH950i. The emulator worked fine on Mac Leopard, but not on XP. Changing the rtscts hardware flow control did not seem to make any difference.

                            Caz

                          • Sally
                            Hi folks, Whilst re-installing my Windows XP laptop ready to take to Maker Faire UK next month I thought that (1) it was a good idea to make sure that the
                            Message 13 of 14 , Mar 27, 2013
                            • 0 Attachment
                              Hi folks,

                              Whilst re-installing my Windows XP laptop ready to take to Maker Faire UK next month I thought that (1) it was a good idea to make sure that the software was working on my machine, and (2) that I should document it to make sure that Windows users don't feel left out. I had written down pretty ropey notes last time, and I couldn't find a site that documented the Windows side of things.

                              So, here goes:

                              Install Python 2.7.3
                              Install PIL 1.1.7
                              Install pyserial 2.6 (remembering to run the [setup.py install] command).
                              Plug in FTDI cable (appropriately configured, lots of info already available on that).
                              Point driver installer at VCP driver (ie. CDM 2.08.28 WHQL Certified).
                              Edit line 287 of PDDemulate.py > change timeout=1 to timeout=5 (this works for Brother 950i, 930 may require timeout=10 given previous post).
                              Download files from GIT (either main trunk for 930, or 950i branch for 950i).
                              Create a CAT batch file, or install the CoreUtils-5.3.0.exe from GnuWin32.sourceforge.net (remembering to add BIN folder to PATH).
                              Reboot.
                              Test saving blank pattern to computer (I used 1x1 cards = 60sts x 150 rows).
                              Test inserting image in to blank pattern, and save back to machine.
                              Test using pattern on machine.

                              All up and running again :-)

                              Happy knitting everyone,
                              Sally

                              --- In kminternals@yahoogroups.com, "andy.caslaw" <andy@...> wrote:
                              >
                              > Bart and others,
                              > I was having the exact same error on XP, "Error, write of N bytes when
                              > expecting 1024", with N around 900 from multiple attempts.
                              > I found that by changing from timeout=1 second, to timeout=10 seconds (
                              > or timeout=none ) the problem went away.
                              > I changed this line in PDDEmulator.py to...
                              > self.ser = serial.Serial(port=cport, baudrate=9600,
                              > parity='N', stopbits=1, timeout=10, xonxoff=0, rtscts=0, dsrdtr=0)
                              > I'm using the FTDI TTL-232R-5V cable with TXD/RXD/CTS/RTS all inverted
                              > and connected with KH950i. The emulator worked fine on Mac Leopard, but
                              > not on XP. Changing the rtscts hardware flow control did not seem to
                              > make any difference.
                              > Caz
                              >
                            Your message has been successfully submitted and would be delivered to recipients shortly.