Incorrect received value callingPresentationAddress in dcmqrscp under Windows

TL;DR:

When I run dcmqrscp under Windows 7 x64 (official current 3.6.2 binaries), the server does not recognize IP of incoming echoscu clients. Instead the value of callingPresentationAddress is set to www or name_of_localhost, depending on the ethernet interface, by which the connection is associated.

Full description

The content of dcmqrscp config file:

NetworkTCPPort  = 11113
MaxPDUSize      = 16384
MaxAssociations = 16
HostTable BEGIN

archive = (ARCHIVE, localhost, 11113)
client1 = (CLIENT1, 146.147.51.82, 12345)
client2 = (CLIENT2, www, 12345)
clients = client1, client2
HostTable END

AETable BEGIN
ARCHIVE   c:/tmp/dcm   RW (100, 1024mb)   clients
AETable END

I connect to the server from Debian machine on 145.146.51.82:

echoscu -d 146.147.51.30 11113 -aec ARCHIVE -aet CLIENT1

Output of the server is as below:

D: $dcmtk: dcmqrscp v3.6.2 2017-07-14 $
D: 
D: setting network send timeout to 60 seconds
D: setting network receive timeout to 60 seconds
D: PDU Type: Associate Request, PDU Length: 205 + 6 bytes PDU header
(...)
D: Parsing an A-ASSOCIATE PDU
I: Association Received (www:CLIENT1 -> ARCHIVE)
D: Parameters:
D: ====================== BEGIN A-ASSOCIATE-RQ =====================
(...)
D: ======================= END A-ASSOCIATE-RQ ======================
D: Peer www:CLIENT1 is not not permitted to access ARCHIVE (see configuration file)
I: Refusing Association (BadAEService)

If I switch calling AE of echoscu to CLIENT2, the answer is positive. This is because of the line in config file client2 = (CLIENT2, www, 12345)

If echoscu is run from the same Windows machine, instead of localhost or 127.0.0.1, the value of callingPresentationAddress is name_of_localhost. This issue was described in this question.

In the opposite direction (echoscu at Windows, dcmqrscp at Debian) everything is correct:

Association Received (146.147.51.30:CLIENT1 -> ARCHIVE)

I suspect that the problem is related to wrong configuration of my Windows, but I have no idea how I should fix it.

PluginNotFoundException: my_theme

We use our own Plugin my_theme

And get an Error:

PluginNotFoundException: my_theme

There was a similiar problem with solution but this those not work (4 years ago)

CKAN: 2.7.2

OS: Centos 7.4

ckan.plugins =webpage_view stats text_view recline_view pdf_view 
geojson_view my_theme resource_proxy
ckan.views.default_views = webpage_view geojson_view pdf_view text_view  recline_view

I installed the Theme with(as described in the manual):

 . /usr/lib/ckan/default/bin/activate
python setup.py develop

How to proceed?

Go: sending and receiving data via USB (GET STATUS, CLEAR FEATURE etc)

I’m trying to develop an alternate client of an old USB device (with no prior experience with USB data transfer protocols). I’ve started tinkering with gousb and for now I’ve understood how to:

  1. access a device
  2. send URB_CONTROL messages
  3. create endpoints and write data

What I haven’t understood yet is how can I send GET STATUS, CLEAR FEATURE or other commands.

To make it clear, I’m listening on the USB port via Wireshark, and this is the command I want to replicate (example, labelled as GET STATUS Status):

Source: (USB device)
Destination: host
IRP USBD_STATUS: USBD_STATUS_SUCCESS (0x00000000)
USB Function: URB_FUNCTION_CONTROL_TRANSFER (0x0008)
IRP information: 0x01, Direction: PDO -> FDO
URB bus id: 1
Device address: 2
Endpoint: 0x00, Direction: OUT
URB transfer type: URB_CONTROL (0x02)
Packed Data Length: 0

The same packet is being sniffed with info CLEAR FEATURE Status after a URB_CONTROL out

Thanks 🙂

EDIT: source files (3 small files) + pcap dump: https://drive.google.com/open?id=1GMfdec_gZ-hBD2BoDw1KTTYEfObHDfic

EDIT2: the pcap stays on Google Drive, while this is the relevant code:

package main

import (
    "log"

    "github.com/google/gousb"
)

func handler(device *gousb.Device) {
    // Start sending messages
    device.Control(0x40, 0, 0xffff, 0x0000, []byte{})
    // ??? GET STATUS
    device.Control(0x40, 1, 0x2000, 0x0000, []byte{})
    // ??? CLEAR FEATURE Status
}

func main() {
    ctx := gousb.NewContext()
    defer ctx.Close()

    devices, err := ctx.OpenDevices(func(desc *gousb.DeviceDesc) bool {
        return desc.Vendor == 0x10c4 && desc.Product == 0xea61
    })

    defer func() {
        for _, device := range devices {
            device.Close()
        }
    }()

    if err != nil {
        log.Fatalf("list: %s", err)

        return
    }

    if len(devices) == 0 {
        return
    }

    var device = devices[0]

    handler(device)
}

SPIR-V error with InterlockedMax after upgrading to LunarG SDK 1.0.68.0

My compute shader (written in HLSL) compiled and worked with the earlier SDK 1.0.65.0. I updated to 1.0.68.0 and recompiled it, now I get this error when calling vkCreateShaderModule:

Vulkan error: [SC], code: 5: SPIR-V module not valid: AtomicSMax:
expected Result Type to be int scalar type

I verified that the error comes from this function in my shader:

groupshared uint ldsZMax;
groupshared uint ldsZMin;
...

void CalculateMinMaxDepthInLds( uint3 globalThreadIdx, uint depthBufferSampleIdx )
{
    float viewPosZ = depthTexture.Load( uint3( globalThreadIdx.x, globalThreadIdx.y, 0 ) ).x;

    uint z = asuint( viewPosZ );

    if (viewPosZ != 0.f)
    {
        InterlockedMax( ldsZMax, z );
        InterlockedMin( ldsZMin, z );
    }
}

I compile the shader with this command:

C:\VulkanSDK\1.0.68.0\Bin\glslangValidator -D -V -S comp -e CSMain LightCuller.hlsl -o LightCuller.spv

The error goes away if I don’t use those Interlocked* methods.
I also tried to use ints instead of uints but the problem persists. What am I doing wrong or could this be a codegen bug?

Spring Validation – Validate list of integers

I have a DTO which has a field List<Integer> amountList . I want to validate that all the elements inside this list are greater than 0 and if not I want to throw a validation error that says which element has failed the validation i.e. “amountList[0] should be greater than 0”, “amountList[1] should be greater than 0”,etc.

I tried to implement the following validator for the above requirement, but I get an error

javax.validation.ValidationException: HV000033: At least one custom
message must be created if the default error message gets disabled.

@Target(ElementType.FIELD)
@Retention(RetentionPolicy.RUNTIME)
@Constraint(validatedBy = PeriodAmountValidationConstraint.PeriodAmountFieldsValidator.class)
public @interface PeriodAmountValidationConstraint {

    String message() default "Period Amount should be greater than 0";

    Class<?>[] groups() default {};

    Class<? extends Payload>[] payload() default {};

    class PeriodAmountFieldsValidator implements ConstraintValidator<PeriodAmountValidationConstraint, List<Integer>> {

        @Override
        public void initialize(PeriodAmountValidationConstraint notEmptyFields) {
        }

        @Override
        public boolean isValid(List<Integer> periodAmountList, ConstraintValidatorContext context) {

            List<Integer> nonNullPeriodAmounts = periodAmountList.stream().filter(Objects::nonNull).collect(Collectors.toList());
            int index = 0;
            context.disableDefaultConstraintViolation();
            boolean validationfailed = false;
            for (Integer nonNullPeriodAmount : nonNullPeriodAmounts) {
                if (nonNullPeriodAmount <= 0) {
                    context.buildConstraintViolationWithTemplate("periodAmountList["+index+"] should be greater than 0")
                            .addConstraintViolation();
                    validationfailed = true;
                }
                index++;
            }
            return validationfailed;
        }
    }
}

I know that I disabled the Constraint Validation, but I added the context.buildConstraintViolationWithTemplate('....').addConstraintViolation(), which as per my understanding should add a custom error message. Obviously this is not working.

What am I doing wrong here ??

Sorting argv Inserts Random Numbers

I am trying to sort *argv[] and I am getting random numbers printing out when i try and display the results of sorting.

#include<stdio.h>
#include <string.h>
#include <stdlib.h>

void sortIntegers(int value[], int length);
int convertToInt(char *string);
int *sortArguments(int argc, char *argv[]);

int main() {

    int i;
    int value[9] = {0, 234, 345345, 91, -3, 12, 3, 19, 17};
    char *argv[9] = {"0", "234", "345345", "91", "-3", "12", "3", "19", "17"};
    int argc = 9;
    int *result;

    printf("\n");

/* order before sorting */
    printf("Before: ");
    for(i = 0; i < 9; i++){
        printf("%d ", value[i]);
    } 
/* end or sorting proof */

/* converting char sting to integers and sorting */
    result =sortArguments(argc, argv);
    printf("\nAfter: ");
    for (i = 0; i < argc; i++) {
        printf("%d, ", result[i]);
    }
    printf("\n");
/* end of sorting and conversion */

/* this is to prove my sort algorith works */
    sortIntegers(value, 9);
    printf("Desired Results: ");
    for(i = 0; i < 9; i++){
        printf("%d ", value[i]);
    }
    printf("\n\n");
/* end or sorting proof */

    free(result);
    return 0;
}

 void sortIntegers(int value[], int length) {     

    int i;
    int x;
    int temp;

    for(x = 0; x < (length - 1); x++)
    {
        for(i = 0; i < (length - x -1); i++)
        {
            if(value[i] > value[i+1])
            {
                temp = value[i];
                value[i] = value[i + 1];
                value[i + 1] = temp;
            }
        }
    }
}
int convertToInt(const char *string) {
    char stringToNum;

    stringToNum = atoi(string);

    return stringToNum;
}
int *sortArguments(int argc, char *argv[]) {

    int *list = malloc(sizeof(int) * (argc));
    int i;    

    for (i = 0; i < argc; i++) 
    {    
        list[i] = convertToInt(argv[i]);
    }
    sortIntegers(list, (argc));

    return list;
}

I have viewed the question Bubble sorting random numbers and I believe i have not committed this error.

here is the output of my program:
Before: 0 234 345345 91 -3 12 3 19 17<br /> After: -22, -3, 0, 1, 3, 12, 17, 19,<br /> Desired Results: -3 0 3 12 17 19 91 234 345345

The before statement comes from a sorting test within my main, that is done correctly, because of this i believe my problem is either with pointer work or calling the function.

does anyone know why sorting would insert random numbers?

Google Drive API – Uploading from MediaFileUpload using blob

I’m trying to upload a file (pdf) to Google Drive via the v3 API, I want to create the file out of an attachment from an email. All the docs that I’ve found seem to rely on a local file where as I want to upload a blob.

Here is the essence of my code so far:

class MailHandler(InboundMailHandler):
  def receive(self, mail_message):
    logging.info("Received a message from: " + mail_message.sender)
    if hasattr(mail_message, 'attachments'):
      logging.info("Has attachments")
      for filename, filecontents in mail_message.attachments:
        file_blob = filecontents.payload.decode(filecontents.encoding)
        credentials = UserModel.query().get()
        media = MediaFileUpload(filename, mimetype = 'image/jpg')
        file = drive.files().create( body = {'name': 'testupload.jpg'}, media_body = media)
        file.execute(c.credentials.authorize(http))

Which throws an error, due the file not existing, which it doesn’t because it is a blob.

Can somebody help me?

Dimming many variables at once and using loop variable inside of them?

I have a number of reports that I am pulling information from and then placing into new fields. I’m wondering if there’s a good way to strucutre it so that, depending on the report type, variables are dimmed to reference the cells that I need, but with the loop counter built-in. Here is a quick mock-up of what I’m looking for:

sub demo()
dim i as long
dim a,b,c,d,e as range

for i = 1 to 100
   if cells(i,1).value2 like "Financials-Q4" Then
     set a = cells(i,21).value2
     set b = cells(i,44).value2
     set c = cells(i,65).value2
  elseif cells(i,1).value2 like "Amor-Q4" Then
     set a = cells(i,100).value2
     set b = cells(i,97).value2
     set c = cells(i,157).value2
     set d = cells(i,89).value2
  end if
next i

 'Start using variables
 for i = 1 to 100
   If a = b Then
      c = "Does not compute"
   Else
      c = "Does compute"
   End if
next i

Currently my code is basically just referencing each individual cell value which is extremely time consuming to clean up / change around.

html input type number with cyclic step

Is it possible to make an html input type “number” to work in a cyclic stepping way?
For example I would like to have the same as it happens with input type “date”.
When you increase the months, after 12 it appears again 1 and so on.
I don’t know if a setting allows cyclic stepping increasing after maximum restart at minimum value or the other way round, decreasing when at minimum value it goes to the maximum etc.
Any ideas?
Thanks